Hi!

I'm trying to automatically import a picture from an url. But I get the error message: Run time error 5152. This is not a valid file name.

It works fine if I do it manually through Insert -> Pictures. And pastes the URL into the file name field.
But if I try with the simple code:



Sub InsertPic()
'
' Test to import pic from url
'
'

Selection.InlineShapes.AddPicture FileName:= _
"https://removeofurl.com/imgapi/imgproxy/img?id=2459&width=1500px&fontsize=24px&zoom=100%25&unofficial=false&topleft =true&target=img-s1" _
, LinkToFile:=False, SaveWithDocument:=True

End Sub


I get the error. Is it that Word don't understand the url due to the &, = and % ? . Cause if you run with a direct link to a image it works as it should. We run a image creator at a webserver that creates the jpg.

Is it possible make Word understand that it is a jpg? Cause it works when you do it manually.

I'm running Word 365 (v 1905)

Thanks

BR
Jorge O