View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Automate Data Entry from .xls to IE

Form elements typically are within a named form and themseleves have a
"name" attribute: they may also have an "id" attribute.

To access a "name"d input you can use:
ie.document.formname.elementname.value="myvalue"

If it has an id then:
ie.document.getElementById("theId").value="myvalue "

To submit a form:

ie.document.formname.submit
or
ie.document.forms(0).submit

If you want to investigate what the names or id's for various elements on a
page are then try this:
http://slayeroffice.com/tools/modi/v2.0/modi_help.html

Tim



"AB" wrote in message
...
I was hoping someone could explain in simple terms how i can make it
work, i.e., how do i write this code.

This is what I'd need:
I need to automate entering data into an IE based form. I got that far
to create IE object and to navigate to the url but i:
1. don't know how to get IE element name;
2. post value to that element;
3. make the code click on the element.

This is the unfinished code.

Sub WebLink()

Dim ie As Object
Dim sURL As String
Set ie = CreateObject("InternetExplorer.Application")

sURL = "http://www.yahoo.com"

ie.Visible = True
ie.Navigate sURL

'wait for response
Do Until Not ie.Busy And ie.ReadyState = 4
DoEvents
Loop

'Here i need a code to:
' 1. enter a value "Australia" in the search box
' 2. Click on "Web Search".

Set ie = Nothing

End Sub

Any help would be extremely helpful as i know something about the VBA
but this is outside my comfort zone. I have, however, achieved the
same result with SendKey - but i wanted to solve it in a bit more
robust way.

Thanks in advance!