Word 2003; I need to paste a picture into the body of the doc. Problem is,
the picture is not on my pc, it's on the web. I have the URL already
calculated by my code and assigned as a string (strURL) So the web address
of the picture is strURL. Can someone please tell me how to 'get' the
picture and then paste it into the document?
thanks, SouthernAtHeart
(I hope this isn't double posted, my machine locked up and I had to start a
new post)
|
|
0
|
|
|
|
Reply
|
Utf
|
1/21/2010 10:24:02 PM |
|
Southern at Heart brought next idea :
> Word 2003; I need to paste a picture into the body of the doc. Problem is,
> the picture is not on my pc, it's on the web. I have the URL already
> calculated by my code and assigned as a string (strURL) So the web address
> of the picture is strURL. Can someone please tell me how to 'get' the
> picture and then paste it into the document?
Okay, so, to answer this, I fired up the Macro Recorder, and offered
the name "PasteImageFromUrl" for the new macro. I then went to
Insert-Picture-FromFile... and gave it the URL. I pressed Enter, and
then stopped the macro recorder. Guesses where this is going? I
opened the VB IDE, navigated to the new macro, and lo and behold...
Sub PasteImageFromUrl()
'
' PasteImageFromUrl Macro
' Macro recorded 1/21/2010 by Karl E. Peterson
'
Selection.InlineShapes.AddPicture FileName:= _
"http://www.google.com/intl/en_ALL/images/logo.gif", _
LinkToFile:=False, _
SaveWithDocument:=True
End Sub
Try it! :-)
--
..NET: It's About Trust!
http://vfred.mvps.org
|
|
0
|
|
|
|
Reply
|
Karl
|
1/21/2010 11:26:53 PM
|
|
GREAT! I've been working on this for days! I've learned a lot from the
macro recorder, but I didn't know word had the insert file from webpage
option!
many thanks.
"Karl E. Peterson" wrote:
> Southern at Heart brought next idea :
> > Word 2003; I need to paste a picture into the body of the doc. Problem is,
> > the picture is not on my pc, it's on the web. I have the URL already
> > calculated by my code and assigned as a string (strURL) So the web address
> > of the picture is strURL. Can someone please tell me how to 'get' the
> > picture and then paste it into the document?
>
> Okay, so, to answer this, I fired up the Macro Recorder, and offered
> the name "PasteImageFromUrl" for the new macro. I then went to
> Insert-Picture-FromFile... and gave it the URL. I pressed Enter, and
> then stopped the macro recorder. Guesses where this is going? I
> opened the VB IDE, navigated to the new macro, and lo and behold...
>
> Sub PasteImageFromUrl()
> '
> ' PasteImageFromUrl Macro
> ' Macro recorded 1/21/2010 by Karl E. Peterson
> '
> Selection.InlineShapes.AddPicture FileName:= _
> "http://www.google.com/intl/en_ALL/images/logo.gif", _
> LinkToFile:=False, _
> SaveWithDocument:=True
> End Sub
>
> Try it! :-)
>
> --
> ..NET: It's About Trust!
> http://vfred.mvps.org
>
>
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
1/22/2010 2:11:01 AM
|
|
Southern at Heart has brought this to us :
> GREAT! I've been working on this for days! I've learned a lot from the
> macro recorder, but I didn't know word had the insert file from webpage
> option!
I never know what I don't know until I know it. <g> Doesn't take long
to try stuff like that, so I did. Voila!
Glad it helped.
--
..NET: It's About Trust!
http://vfred.mvps.org
|
|
0
|
|
|
|
Reply
|
Karl
|
1/22/2010 3:04:55 AM
|
|
I am also needing to resize this picture. I know how to record a macro
resizing a picture, but here's my problem:
I want to resize the picture to--the page width minus the right and left
margins.
So what ever the current page width is, minus the right and left margins, I
want to resize the picture to this, keeping the aspect ratio. There must be
a page property or something that tells me the page size/margins?
thanks.
"Southern at Heart" wrote:
> GREAT! I've been working on this for days! I've learned a lot from the
> macro recorder, but I didn't know word had the insert file from webpage
> option!
> many thanks.
>
>
> "Karl E. Peterson" wrote:
>
> > Southern at Heart brought next idea :
> > > Word 2003; I need to paste a picture into the body of the doc. Problem is,
> > > the picture is not on my pc, it's on the web. I have the URL already
> > > calculated by my code and assigned as a string (strURL) So the web address
> > > of the picture is strURL. Can someone please tell me how to 'get' the
> > > picture and then paste it into the document?
> >
> > Okay, so, to answer this, I fired up the Macro Recorder, and offered
> > the name "PasteImageFromUrl" for the new macro. I then went to
> > Insert-Picture-FromFile... and gave it the URL. I pressed Enter, and
> > then stopped the macro recorder. Guesses where this is going? I
> > opened the VB IDE, navigated to the new macro, and lo and behold...
> >
> > Sub PasteImageFromUrl()
> > '
> > ' PasteImageFromUrl Macro
> > ' Macro recorded 1/21/2010 by Karl E. Peterson
> > '
> > Selection.InlineShapes.AddPicture FileName:= _
> > "http://www.google.com/intl/en_ALL/images/logo.gif", _
> > LinkToFile:=False, _
> > SaveWithDocument:=True
> > End Sub
> >
> > Try it! :-)
> >
> > --
> > ..NET: It's About Trust!
> > http://vfred.mvps.org
> >
> >
> > .
> >
|
|
0
|
|
|
|
Reply
|
Utf
|
1/22/2010 3:45:01 AM
|
|
It doesn't work!
When I run my completed code, I get the message:
'The graphics filter was unable to convert this file'
Any ideas?
the picture in this case is located at:
http://imgsrv.gocomics.com/dim/?fh=fd933fd26e764bfd5ca061710701f811&w=900.0
thanks again.
|
|
0
|
|
|
|
Reply
|
Utf
|
1/22/2010 4:16:01 AM
|
|
http://imgsrv.gocomics.com/dim/?fh=fd933fd26e764bfd5ca061710701f811&w=900.0
or, rather...
?fh=fd933fd26e764bfd5ca061710701f811&w=900.0
is NOT a valid file format to Word. This is the whole point of web-based
images doing this.
If you notice the previous example had a .GIF extension. This Word
understands.
Southern at Heart wrote:
>It doesn't work!
>When I run my completed code, I get the message:
>'The graphics filter was unable to convert this file'
>Any ideas?
>the picture in this case is located at:
>http://imgsrv.gocomics.com/dim/?fh=fd933fd26e764bfd5ca061710701f811&w=900.0
>
>thanks again.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201001/1
|
|
0
|
|
|
|
Reply
|
Fumei2
|
1/22/2010 9:03:18 PM
|
|
It happens that Southern at Heart formulated :
> It doesn't work!
> When I run my completed code, I get the message:
> 'The graphics filter was unable to convert this file'
> Any ideas?
> the picture in this case is located at:
> http://imgsrv.gocomics.com/dim/?fh=fd933fd26e764bfd5ca061710701f811&w=900.0
You'll need to use "another method" to download it, saving to a temp
file, then opening the saved temp file. Here's one way:
http://vbnet.mvps.org/code/internet/urldownloadtofilenocache.htm
If this were VB6, I'd point you instead towards the AsyncRead method of
a UserControl - http://vb.mvps.org/samples/NetGrab
Problem just got messier.
--
..NET: It's About Trust!
http://vfred.mvps.org
|
|
0
|
|
|
|
Reply
|
Karl
|
1/23/2010 1:13:52 AM
|
|
|
7 Replies
1091 Views
(page loaded in 0.15 seconds)
|