Inlineshape @ bookmark

D

dunnerca

I am trying to insert a picture (signature bmp file) at a specific bookmark
in my template. I can get the file inserted and change the size; however, I
cannot get it to be inserted at the bookmark that I have specified. Any
ideas? Thanks.
 
J

Jay Freedman

dunnerca said:
I am trying to insert a picture (signature bmp file) at a specific
bookmark in my template. I can get the file inserted and change the
size; however, I cannot get it to be inserted at the bookmark that I
have specified. Any ideas? Thanks.

You need to include the optional parameter named Range in the AddPicture
command, and pass it the range of the desired bookmark.

Inserting the picture at the bookmark will destroy the bookmark, so you also
need to reinsert that. Here's sample code:

Dim myRange As Range
Dim ILS As InlineShape
Dim ratio As Single

Set myRange = ActiveDocument.Bookmarks("bk1").Range

Set ILS = ActiveDocument.InlineShapes.AddPicture( _
FileName:="C:\My Pictures\something.jpg", _
Range:=myRange)
With ILS
ratio = InchesToPoints(2.5) / .Width
.Width = ratio * .Width
.Height = ratio * .Height
End With

ActiveDocument.Bookmarks.Add Name:="bk1", Range:=myRange

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top