Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Control Webbrowser with VB6

Posted on 2011-03-20
9
Medium Priority
?
485 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 20

Accepted Solution

by:
darbid73 earned 2000 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
 

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 20

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 20

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Suggested Courses

664 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