0
votes

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?

1
do you want to do it manually or using any code (vba?). if code- do you have any initial code already?... to make it clear: image from web based on url to bookmark range?Kazimierz Jawor
What I have is a template composed mostly from bookmarks so not really manually but I am not generating it from code either.BulletVictim
The Image I want to add is a static google maps image and the URL is a varchar in my databaseBulletVictim
this question is quite similar to previous one of yours. to get an answer you need to be more precise, answer questions from comments, provide as much information as possible... Anyway, I would say it's possible what you need and could be done with word-vba, but I don't know how to do it with C#,asp.net and other (which you refer in the other question). So, be precise to get help!Kazimierz Jawor
I am trying to be as precise as possible, but due to the terms of my employment I am not able to give out a lot of information about this as these are legal documents. If you know how to do it with word-vba that would be greatly appreciated. The reason I posted this question is because the requirements on how to do it has changed since in the previous question I was trying to get an image directly from the google maps api v3 control I was using. I am now doing this completely differently.BulletVictim

1 Answers

0
votes

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