VBA getting excel data from a webpage without HTML

143 Views Asked by At

I am trying to get copy data from a web link that displays the excel file directly. I cannot right click and select inspect element for the HTML code as the link opens the excel file. (image atachde)

enter image description here

Now the task is to copy the data from this file and paste in the local file. I can acces the file but since the HTML code is not accesible, class method does not work. Secondly, the normal workbook to workbook code also does not work as one of the workbook is an online link. Followoing is the code that I have but it does not work:

Sub OpenAndGetData()
Dim objIE As Object
On Error GoTo error_handler
Application.EnableEvents = True
Set objIE = CreateObject("InternetExplorer.Application")

With objIE
'(This is a direct link to the excel file that opens it online)
.navigate "myinternalinkhere"
objIE.Visible = True

End With

Workbooks("online_file.xlsx").Worksheets("sheet1").Range("B1:C500").Copy _
        Workbooks("local_file.xlsm").Worksheets("Sheet1").Range("A1")

Exit Sub

error_handler:
MsgBox ("Unexpected Error, I'm quitting.")
' objIE.Quit
Set objIE = Nothing



0

There are 0 best solutions below