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

    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