Solved

Automate w/o SendKeys

Posted on 2011-03-20
2
260 Views
Last Modified: 2012-06-27
So I'm learning that sendKeys is not the best idea when trying to automate a web page.  I'm finding many resources for VB.net, but not so much for VB6.

So, Can someone help me figure out how to open www.google.com in webbrowser1, type "Hello World" in the search box and hit submit?
0
Comment
Question by:hrolsons
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35176259
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 35186659
Create a New Project (Project1)
Add a Form (Form1)
Add a WebBrowser (WebBrowser1) (You will have to add a reference in Components to "Microsoft InternetControls")

Place the code below to the form by double clicking on the form

Maximize the form to full screen (as far as possible) then stretch the Browser to fill the Form.

Run the Project.

Hope that is what you are after.  :-)
Option Explicit

Private bFirstPage As Boolean

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

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
  If bFirstPage Then
    bFirstPage = False
    WebBrowser1.Document.All.Item("q").Value = "Hello World"
    WebBrowser1.Document.All("btnG").Click
  End If
End Sub

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 72
VBA error replacing data 6 40
How to make an ADE file by code? 11 87
VB6 - Scroll Mouse wheel on Picturebox 13 44
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

810 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