Yann Shukor
asked on
Use VBA to paste an image in a Winword document using a URL
Hi
I work with PRTG and provide one of my clients with a weekly reports.
I'd like to automate the process by using VBA to collect graphs from PRTG and insert them into a table in Winword 2013.
The URL look like this :
When I load this in a browser I obtain the expected result : a graph in PNG format
Is it possible to use VBA in order to collect and insert these graphs into my word document ?
thanks
yann
I work with PRTG and provide one of my clients with a weekly reports.
I'd like to automate the process by using VBA to collect graphs from PRTG and insert them into a table in Winword 2013.
The URL look like this :
http://XXX.XXX.XXX.XXX:8080/chart.png?type=graph&width=400&height=200&graphid=2&id=5493
When I load this in a browser I obtain the expected result : a graph in PNG format
Is it possible to use VBA in order to collect and insert these graphs into my word document ?
thanks
yann
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This works for me:
And so does this:
My guess is that the problem you're facing stems from the fact that the url doesn't point to an existing picture, it generates it.
Sub InsertURLGraphic()
With Dialogs(wdDialogInsertPicture)
.Name = "http://experts.cachefly.net/files/2014/05/29/3c477867-0ec6-4a3b-9d33-9f35bfe2021a.JPG"
.Execute
End With
End Sub
And so does this:
Sub InsertURLGraphic()
With Dialogs(wdDialogInsertPicture)
.Name = "http://experts.cachefly.net/files/2015/07/15/792b93a5-3afc-4142-a1a8-f63589776532.png"
.Execute
End With
End Sub
My guess is that the problem you're facing stems from the fact that the url doesn't point to an existing picture, it generates it.
ASKER
Thank you MacroShadow
I will query Paessler and get back to you
I will query Paessler and get back to you
What did they say?
ASKER
They confirmed that there was effectively no image, just a link that generates the image on the fly
They offered the following alternative:
What do you think ?
regards
yann
They offered the following alternative:
Sub Example1()
Selection.InlineShapes.AddPictrure FileName:= _
"http://XXX.XXX.XXX.XXX:8080/chart.png?type=graph&width=400&height=200&graphid=2&id=5493", _
LinkToFile:=False, SaveWithDocument:=True
End Sub
What do you think ?
regards
yann
Did you try it?
ASKER
Ok, I just tested it and it works
I did however have to set the image format to PNG
because Word displayed a square with "This image cannot be displayed" when the format was set to SVG
I did however have to set the image format to PNG
because Word displayed a square with "This image cannot be displayed" when the format was set to SVG
ASKER
Same error, is the problem with PRTG or Winword ?