View Single Post
 
Old 11-20-2015, 06:09 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Hi Paul,

Did you test your method? I didn't and it appears we could both be wrong. It seems that unlike .Range.Text = "Whatever", .Range.InlineShapes.AddPicture is not destructive. The bookmark is not destroyed and the range is expanded to include the inlineshape and previous text. Your .delete just deletes the bookmark leaving the ISL and text intact. My method was no better. Perhaps tjis will meet the OP needs:

Code:
Sub Test()
Dim oRng As Range
With ActiveDocument
  If .Bookmarks.Exists("Sig1") = True Then
    With .Bookmarks("Sig1")
      Set oRng = .Range
      oRng.Text = vbNullString
      ActiveDocument.Bookmarks.Add "Sig1", oRng
     .Range.InlineShapes.AddPicture FileName:="C:\Sig1.png"
     .Delete 'Delete the bookmark
    End With
  ElseIf .Bookmarks.Exists("Sig2") = True Then
     With .Bookmarks("Sig2")
     Set oRng = .Range
     oRng.Text = vbNullString
     .Range.Bookmarks.Add "Sig2", oRng
     .Range.Text = vbNullString
     ActiveDocument.Bookmarks.Add "Sig1", oRng
     .Range.InlineShapes.AddPicture FileName:="C:\Sig2.png"
     'or keep the bookmark
    End With
  End If
End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote