A family of Microsoft word processing software products for creating web, email, and print documents.
Hi JDN_321,
As of writing this, still have this error (on a 64-bit version of Word 2016)! Further, I'm also getting no response to this long outstanding issue.
I even tried to directly contact MS support, but they would only discuss the issue if I paid for a support call! Considering this was a longstanding macro that had worked flawlessly until some mysterious "change" in the environment rendered it useless, I chose to not pay.
While, to my knowledge, no solution exists for this error, I have devised a work-around. I'm really not happy about this as there is nothing to say the same problem will not occur with the alternative code in the future.
Having said that, here's a way to insert an image in a canvas that works for me, with a few caveats:
- Obviously the image file in the code has to exist in the specified location
- The shape has to be the created with correct dimensions for the inserted image
Sub NewPictureFill()
Dim i As Integer
Dim shpCanvas As Shape
Dim shpPicture As Shape
'Add a drawing canvas to the active document
Set shpCanvas = ActiveDocument.Shapes _
.AddCanvas(Left:=100, Top:=125, _
Width:=400, Height:=400)
'Add a graphic to the drawing canvas
Set shpPicture = shpCanvas.CanvasItems.AddShape(Type:=msoShapeRectangle, Left:=25, Top:=25, Width:=90, Height:=90)
shpPicture.Fill.UserPicture "C:\Users\Public\Pictures\test.jpg" 'CHANGE THIS to image file on your PC!
End Sub
While there may be a clever way to automatically resize the shape to suit the inserted image, this is only a proof of concept test sub, so I have not taken it any further!