VBA Insert Image from URL

image from url

How to insert image from URL to Word bookmark?

10.10.2021, Goran Dolenc
Categories: VBA Word
Tags: VBA Word

To insert picture at bookmark:

    Sub Insert_picture_To_Bookmark()

        Dim mapURL As String
        Dim soLOGO As String

        soLOGO = "http://myurl/myimage.png"
        ActiveDocument.Bookmarks("bookmark_logo"). _
                        Range.InlineShapes.AddPicture _
                        soLOGO, True, True

        mapURL = "https://maps.google.pl/maps?q=..."
        ActiveDocument.Bookmarks("bookmark_poland"). _
                        Range.InlineShapes.AddPicture _
                        mapURL, True, True

    End Sub

And to position and size image:

    Sub InsertImage()

    Dim imagePath As String

        imagePath = "C:\\picture.jpg"

        ActiveDocument.Shapes.AddPicture FileName:=imagePath, LinkToFile:=False, SaveWithDocument:=True, Left:=-5, Top:=5, Anchor:=Selection.Range, Width:=20, Height:=20

    End Sub