I am currently working on a macro that would open links to pages from column A (pages in column A could be, for example, 10 from a1 to a10) then select everything and copy to Excel, e.g. to the Page Sheet, every generation. Here's my initial macro:
Sub www()
Dim mmnt!
Dim strUrl$
Dim ie As Object
strUrl = "http:"
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate strUrl
While (ie.Busy Or ie.readyState <> 4): DoEvents: Wend
mmnt = Timer: While Timer - mmnt < 2: DoEvents: Wend
ie.ExecWB 17, 0
ie.ExecWB 12, 2
Range("A1").Select
ActiveSheet.PasteSpecial Format:="HTML", link:=False, NoHTMLFormatting:=True
ie.Quit
Set ie = Nothing
End Sub
Unfortunately, the macro does not work on some internal pages. The problem occurs after Internet Explorer has been successfully launched and the page loads immediately receives the error message:
Run-time error - 2147467259 (80004005)
While (ie.Busy Or ie.READYSTATE <> 4): DoEvents: Wend
I have a question how to deal with it? How to improve the macro?
Aucun commentaire:
Enregistrer un commentaire