Hi, I'm currently working on a macro whose task is to open links to pages, and then after opening the page would mark everything and copy to Excel, e.g. to a page sheet. Here is my macro:
Unfortunately, the macro stops after pasting into Excel. I receive the following message. It seems to me that this is because nothing is selected and copied.
run-time error '1004' The PasteSpecal method from the Range class failed
The macro has stopped on:
I noticed that the above macro works in a situation where quickly after starting InternetExplorer as the page loads, I press any field in the browser. I have a question whether it is possible to improve the macro to load without my interference.
VBA Code:
Sub VBA()
Dim mmnt!
Dim strUrl$
Dim IE As InternetExplorerMedium
strUrl = "http:"
Set IE = New InternetExplorerMedium
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 stops after pasting into Excel. I receive the following message. It seems to me that this is because nothing is selected and copied.
run-time error '1004' The PasteSpecal method from the Range class failed
The macro has stopped on:
VBA Code:
ActiveSheet.PasteSpecial Format:="HTML", link:=False, NoHTMLFormatting:=True
I noticed that the above macro works in a situation where quickly after starting InternetExplorer as the page loads, I press any field in the browser. I have a question whether it is possible to improve the macro to load without my interference.