Inserting HTML images in a Word doc

D

dcarva

Hello,

I recorded a Word macro that inserts an image that exists on the internet. I
started recording and went to Insert->Picture->From File. Then I inserted the
URL in the path bar. The file inserted fine and the vba code was recorded.
However, when I play back the macro, it says "Error 5152" - something about
the file not being valid. Anyone know how I can do something like this? I
have images on a webserver that I want to display on my page using a macro. I
am using Word 2000. Here is the vba code it records:

Selection.InlineShapes.AddPicture FileName:= _
"http://www.site.com/test.gif", _
LinkToFile:=False, SaveWithDocument:=True

Thanks
Danny
 
J

Jezebel

There's nothing wrong with the code as such. Error 5152 is not a built-in
error (ie it's not generated by Word itself) so one can't comment on what it
means; presumably there is, in fact, some problem with the filename you've
used, or the server was not serving at the time.

But what do you have in mind for the macro? -- presumably you don't want to
insert the same file every time. Are you writing a separate macro for each
graphic?
 
D

dcarva

Basically,

I have a word doc that creates flyers for soccer teams. The coaches run a
macro that lists players from a SQL Server database. They select the player,
click a button on the form, and the flyer is generated with the selected team
members. All of the data is read from a SQL Server. (they are accessing the
data over the internet) Somewhere in the loop, I also load the player's
picture. The graphics are stored on a web server. But you have to download
the picture onto your hard drive to get to work. (I have to send the graphics
to the coaches) I want to bypass this step and just be able to insert the url
of the image. The server was indeed serving the graphic at the time. In fact,
I can even manually insert the graphic into Word using a url. The urls I use
are good. Error 5152 means invalid file name. So, basically, the macro cannot
play back what it recorded in this case. I was looking for a workaround.
Thanks for reading this post.

Danny
 
J

Jezebel

Not sure where the problem is, then. If you set up that macro with a valid
filename, it certainly works.
 
D

dcarva

Yeah. Thanks for looking at this. Danny

Jezebel said:
Not sure where the problem is, then. If you set up that macro with a valid
filename, it certainly works.
 
G

Griffin

Is it possible that the query to the database is extracting the image from a
fiels and making a temporary file while the page is being viewed (session is
active). If so, the desired file may have already been erased by the time yo
go to get it later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top