The following code works well for what I need but I have one question/inquery - it relies on a bookmark on the page where the image is to be inserted - can I modify this and use something like activeDocument so I don't have to use bookmarks?
Visual Basic Classic
Last Comment
sbsbats
8/22/2022 - Mon
sbsbats
ASKER
Sub InsertPictureShape()
Dim sh As Shape
With ActiveDocument
Set sh = .Shapes.AddPicture("C:\image\sbs.png", False, True, , , , .Bookmarks("logo").Range)
sh.RelativeHorizontalPosition = wdRelativeHorizontalPositionLeftMarginArea
sh.RelativeVerticalPosition = wdRelativeVerticalPositionTopMarginArea
sh.Top = CentimetersToPoints(0.8)
sh.Left = CentimetersToPoints(12.2)
End With
End Sub
GrahamSkan
The code uses ActiveDocument.Bookmarks("logo").Range. That's how the With block works.
You have to specify where you want the picture. If you don't know it in terms of the Word object, can you describe in words where you need the picture?
sbsbats
ASKER
on the active page - i.e if the doc has more than one page then the page with the cursor on it
Dim sh As Shape
With ActiveDocument
Set sh = .Shapes.AddPicture("C:\ima
sh.RelativeHorizontalPosit
sh.RelativeVerticalPositio
sh.Top = CentimetersToPoints(0.8)
sh.Left = CentimetersToPoints(12.2)
End With
End Sub