Frage

I have a image URL contained in my sql database. I create a bookmark for that column in the word document (this works fine).

Now I want to use the image URL that is passed from the database to insert an image.

I have tried hyperlink (does not work and does not display image).
I have tried Quick Parts - IncludePicture (does not work).

I have been Googleing and have not found anything that works.

Ok let me simplify this. I want to insert a image using an URL. You can do this in alot of different ways I know.

For instance using Quick Parts and the selecting IncludePicture you would the past the URL of the picture and BAM image inserted.

Now I want to do exactly that with one exception. The URL is a microsoft word bookmark that I get from my database. For some reason this does not want to work. I have also checked the bookmark data and it is correct and yes it is a valid URL because if I copy and paste it from the database in the way I described above it works.

So is there any other way to do this?

War es hilfreich?

Lösung

To be honest I still don't know where is exactly your problem. I assumed that you have knowledge and code to take both bookmark name and url from your database using VBA. If so, there would be quite simple code which would allow you to load picture from web to bookmark in your word document.

Below is the code I have tested with half of success. If I add any picture it will work fine. But will not work with url of active google map. I have no idea what you you mean with 'static google map' (in comment), you didn't provide any example therefore you need to make your own test.

Before you run this for test be sure you have two bookmarks in your active document: bookmark_logo and bookmark_poland. Hope this will help a bit.

Sub Insert_picture_To_Bookmark()

    Dim mapURL As String
    Dim soLOGO As String

    soLOGO = "http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png"
    ActiveDocument.Bookmarks("bookmark_logo"). _
                    Range.InlineShapes.AddPicture _
                    soLOGO, True, True

    mapURL = "https://maps.google.pl/maps?q=poland&hl=pl&sll=50.046766,20.004863&sspn=0.22047,0.617294&t=h&hnear=Polska&z=6"
    ActiveDocument.Bookmarks("bookmark_poland"). _
                    Range.InlineShapes.AddPicture _
                    mapURL, True, True

End Sub
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top