John, are you trying to fill in a form on a webpage or send a command to the
browser itself (such as "open page
www.123.com)?
If you are trying to fill in a form on a page, my first guess is that you
aren't waiting long enough for the page to fully load. With the following
code I was able to browse to
www.funny.com and enter "test" into the search
box. Sendkeys is very finicky and I would only use it as a last resort. If
the web page orientation (layout, tab-index, etc.) ever changes, your code
will break.
Regards,
Bill
Public Sub Test_IESendkeys()
Dim i As Long
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "http://www.funny.com"
.resizable = True
End With
Application.Wait (Now + TimeValue("0:00:10"))
'App.Activate "Microsoft Internet Explorer"
For i = 1 To 15
SendKeys "{TAB}"
Next i
SendKeys "test"
'SendKeys "~"
End Sub
"John" wrote:
Code is simple... and there is no error in code (that VBA discerns) but the
sendkeys commands do not move the cursor in the new IE window and doesn't
send the active cell value either. Any thoughts?
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "http://whatever.com"
.resizable = True
End With
'App.Activate "Microsoft Internet Explorer"
SendKeys "{TAB}"
SendKeys ActiveCell.Value
SendKeys "~"