2

I have a map on a website which changes with time (interactive) and I would like to insert it on the excel sheet.

I am using this code but it does not show the HTML:

Private Sub Mapit()
URL = Sheets("sheet1").Cells(1, 1) //Here there is written the link to the website that want to show on excel
Sheets("sheet1").Pictures.Insert(URL).Select End Sub

Is that possible? I guess that Sheets("sheet1").Pictures.Insert(URL).Select is the problem but I am not able to find which is the correct way.

Thank you for your time

Community
  • 1
  • 1
yke
  • 129
  • 3
  • 3
  • 10

1 Answers1

3

Try this. You are almost there. No need for .Select

Sub Mapit()

    Dim URL As String
    URL = "https://www.google.com/images/srpr/logo9w.png"
    ActiveSheet.Pictures.Insert (URL)

End Sub


Private Sub Mapit()

    Dim URL As String
    URL = Sheets("sheet1").Cells(1, 1)

    ThisWorkbook.Activate
    ThisWorkbook.Sheets("sheet1").Select
    Sheets("sheet1").Pictures.Insert (URL)

End Sub

Updated after comments :

Insert Userform > Goto toolbox > Additional COntrols > Select Microsoft Web Browser > OK

Drag the control to userform

Now on userform paste below code

Private Sub UserForm_Initialize()
    Me.WebBrowser1.Navigate ("www.google.com")
End Sub
Santosh
  • 12,175
  • 4
  • 41
  • 72
  • Hello Santosh and thanks a lot for your time but the problem is that what I want is to show to be able to have the complete website on my excel sheet. I dont know if it is possible to get that. Is it? – yke Mar 06 '14 at 12:24
  • @yke I have updated the answer. Is that what you are looking for ? – Santosh Mar 06 '14 at 12:31
  • I think it is that. YES, but I am getting an error in Me.WebBrowser1 (ERROR OR DATA MEMBER NOT FOUND) – yke Mar 06 '14 at 12:48
  • Didn't know this was possible! Thanks :) still useful after all these years – hammythepig Feb 27 '19 at 16:32
  • Related SO question about Microsoft Web Browser Control: https://stackoverflow.com/questions/35024440/how-to-make-microsoft-web-browser-object-work-in-excel-2016 – Stefan Jan 03 '22 at 16:24