PDA

View Full Version : Edit code



av8tordude
05-30-2011, 08:19 PM
I have this code that opens my site and clicks a paypal link on my site to open PayPal. It works well, but I ran into a problem that if the browser opens, but does not load, the code hangs, and locks up. Can someone assist with editing this code that will allow me to break or stop the code.

thanks

Sub PayPal()
Dim objExcel
Dim objIE
Dim varForm
Dim URL
Set objExcel = ActiveWindow.ActiveSheet
URL = "mysite.com"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False 'set to true when debugging. Keep it hidden for the moment.
With objIE
.Navigate URL
End With
While objIE.Busy
Wend
While objIE.document.ReadyState <> "complete"
Wend
Set varForm = objIE.document.forms(0)
varForm.submit
frmActivate.Height = 418
DemoProgress1
While objIE.Busy 'wait for internet explorer to stop doing whatever it is it might doing...
Wend
apiShowWindow objIE.hwnd, SW_MAXIMIZE 'set to true to show website.
objIE.Visible = 1
Set objIE = Nothing
End Sub

Simon Lloyd
05-30-2011, 08:35 PM
You might find this useful by Leith Ross, he includes a "wait for website to complete" that may help you http://www.thecodecage.com/forumz/members-excel-vba-programming/208422-import-web-data-into-excel.html#post743168