ok, one question: why is there the 20 second delay after the Sendkeys?
I have two suggestions to try:
this is some code I wrote to open a new ie page (navigating to Google), waiting until ie ready, then pasting some previously copied text ("FText") from the ClipBoard.
Set newpage = New InternetExplorer
newpage.Visible = True
newpage.Navigate ("www.translate.google.com")
Do
Loop Until newpage.ReadyState = READYSTATE_COMPLETE
MyData.GetFromClipboard
FText = MyData.GetText
Sec1 = Now + TimeValue("00:00:04")
Do Until Now > Sec1
DoEvents
Loop
SendKeys ("^v"), True
maybe you can substitute the Google line with your web address for the file. The programme pauses until ie is ready but then i found that I had to introduce the 4 second delay before pasting in the Clipboard using the Sendkeys CTRL V but you'll need to change this to "O" (see comment on Sendkeys below).
Also make sure that you have the right References checked ("Tools", "References") as I think you might need the Microsoft Internet Controls ref checked. (Might be wrong though...)
Alternatively, you could put the sendkeys and Windows.Activate command in a separate sub (YourSubName) and use the following Code to call the sub to run after a period of time (in this case 20 seconds) and then sub continues with the rest. if the time is sufficient, this should allow ie to catch up and be ready for the sendkeys commands that you sent earlier.
DDuration = Now + TimeValue("00:00:20")
Application.OnTime DDuration, "YourSubName"
your ie stuff here
To see how the Ontime works, paste the following into a new module of a new book and then run the "testontime" macro to see what happens.
Public Sub testontime()
waittime = Now + TimeValue("00:00:05")
Application.OnTime waittime, "NextMsg"
MsgBox "ha!"
End Sub
Public Sub NextMsg()
MsgBox "Next MsG"
End Sub
Lastly, using Sendkeys can be temperamental and I've found that using/not using brackets (as in my example) can make a difference. Just have to try the different approaches I'm afraid.
Bookmarks