Macro copying website

Max_hugo

New Member
Joined
May 3, 2020
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
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:

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.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
The URL is the internal page in my work, I can only launch it in my position. I would like to download data for the report from it.
 
Upvote 0
I have a question whether it is not possible after providing the URL to go to the window with the website and then select everything and copy the page?
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,770
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top