View Single Post
 
Old 11-20-2015, 02:03 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Greg,

I was assuming the bookmark was empty before inserting the InlineShape. In that case, the code I posted should work just fine. That said, the OP has a solution, so NFA required.

Generically, the code to update the pic in a bookmarked range would be:

Code:
Sub Demo()
Dim wdRng As Range, BkMkNm As String
BkMkNm = "MyBookmark"
With ActiveDocument
  'Confirm that the bookmark exists
  If .Bookmarks.Exists(BkMkNm) Then
    Set wdRng = .Bookmarks(BkMkNm).Range
    'Delete existing contents
    wdRng.Text = vbNullString
    'Insert Pic
    .Range.InlineShapes.AddPicture FileName:="PictureFullName", Range:=wdRng
    'Extend Range
    wdRng.End = wdRng.End + 1
    'Re-apply bookmark
    .Bookmarks.Add BkMkNm, wdRng
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote