Word vba fill shape with userpicture assigned to a string variable

Evil Devil 1 Reputation point
2021-09-11T12:41:30.857+00:00

Hi all,

This question has been asked before here :

https://social.msdn.microsoft.com/Forums/en-US/8eda76bd-841e-49a3-935e-5df07908f6c0/cannot-set-a-shapefilluserpicture-mystringvar-with-a-string-variable-using-a-literal-does-work?forum=worddev

back in 2012 but it doesn't seem to solve my problem. I have office 2016 here and the bug still persists. If i use

shp.Fill.UserPicture "C:/.../somepicture.png"

it works but if I do

Dim myStr as string
myStr = "C:/.../somepicture.png"
shp.Fill.UserPicture myStr

it throws an error: method 'UserPicture' of object 'FillFormat' failed
The same goes for Dir() function. When supplied a variable instead of a string literal, it throws error: Bad file name or number
please note, shp is dimmed as Shape and I am loopimg through AtiveDocument.Shapes for each shp

Would really appreciate if somebody could help!

Word Management
Word Management
Word: A family of Microsoft word processing software products for creating web, email, and print documents.Management: The act or process of organizing, handling, directing or controlling something.
896 questions
{count} votes