Solved

Control Webbrowser with VB6

Posted on 2011-03-20
9
478 Views
Last Modified: 2012-05-11
I'm trying to use the advice from this post:

http://www.experts-exchange.com/Programming/Languages/Q_21776208.html

But I keep getting:

"Object doesn't support this property or method"

On the line of code that "Clicks"
0
Comment
Question by:hrolsons
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Expert Comment

by:Rikin Shah
ID: 35178077
I'm not a premium member yet... So can't read the solution you provided with above links...

Per my understanding whatever value you get from name and other fields, you could pass those values with the URL and Query String.

like http://www.google.com/pagename.htm?name=valueFromTextBox

I think this would work.
0
 

Author Comment

by:hrolsons
ID: 35178105
When I click your link it's error
0
 
LVL 19

Expert Comment

by:Rikin Shah
ID: 35178376
That is just an example...

You just need to replace the variable name from "name" to your required variable and its value which you captured from VB. Here I have added "valueFromTextBox"

You need to dynamically pass the URL from code and read the values from querystring to show them on the web page you're showing.
0
 
LVL 19

Accepted Solution

by:
darbid73 earned 500 total points
ID: 35178475
That code works fine.

Look at this part here

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If firstPage Then
        firstPage = False


        WebBrowser1.Document.All.Item("q").Value = "Idle_Mind"
        WebBrowser1.Document.All("btnG").Click
    End If
End Sub

Open in new window


This is an event that happens when the document - ie the HTML document is downloaded from google and in your webbrowser.  Maybe this is not really finished.

To test this put something like this in there after the firstpage = False

msgbox "Just to pause things"

Then run and when you see the message wait a second and then click ok to let the code continue.

There is another was of doing this with the READYSTATE property of the webbrowser which is what we might also use if this is your problem.

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:hrolsons
ID: 35181621
darbid73:  Tried that and got the same thing.

rikin shah:  I know see that your code was just an example, silly me.
0
 
LVL 19

Expert Comment

by:darbid73
ID: 35182222
then you need to show your full code.
0
 

Author Comment

by:hrolsons
ID: 35182446
I have a blank form with 1 webbrowser control called webbrowser1:

Option Explicit

Private firstPage As Boolean

Private Sub Form_Load()
    firstPage = True
    WebBrowser1.Navigate2 "www.google.com"
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If firstPage Then
        firstPage = False
        MsgBox "Just to pause things"
        WebBrowser1.Document.All.Item("q").Value = "Idle_Mind"
        WebBrowser1.Document.All("btnG").Click
    End If
End Sub
0
 
LVL 19

Expert Comment

by:darbid73
ID: 35182497
There is nothing wrong with the code.

does the webbrowser actually go to google.com?

Sometimes google goes to local sites instead.

If yes open the page with the navigate in the webbrowser control.  Then you get your error.  Then right click on it and view source.  Then save the source as a txt file and upload it.
0
 

Author Comment

by:hrolsons
ID: 35182700
I turned off "Instant Search" and it is working now.  Thank you for helping me work through that.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now