Solved

Control Webbrowser with VB6

Posted on 2011-03-20
9
480 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
LVL 20

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
 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

830 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