VBA to work with existing IE window/url

M

Mike

I am working on an application that will be run when a IE window is
already open to the correct page URL (the URL is a dynamic name- it
changes every time). I need the application to fill in 2 form text
fields and click the submit button. I found this example code that
works by navigating a new IE window to a fixed URL and it works great-
but how can I change this to fill in the fields to an already open IE
window ? I have played around with the FindWindow function and the
AppActivate, but cannot make this all work...

thanks for any help on this.

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "http://www.usps.com/ncsc/lookups/lookup_ctystzip.html"
IE.Visible = True
While IE.Busy
DoEvents
Wend

Set ipf = IE.document.All.Item("city")
ipf.Value = "12345" 'fill in the text box
Set ipf = IE.document.All.Item("submit1")
ipf.Click 'click the submit button
IE.Quit
 
T

Tim Williams

Dim IE,ipf
Set IE = GetObject(,"InternetExplorer.Application")
IE.document.All.Item("<input name>").Value="12345"
IE.document.All.Item("<input2 name>").Value="abcde"
Set ipf = IE.document.All.Item("<submit name>")
ipf.Click 'click the submit button

untested but should work
Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top