VBA: Add/remove bookmarked image into word document.

ActiveDocument.Bookmarks("TEST").Range.InlineShapes.AddPicture FileName:="P:\test.png" 1. Bookmark the inserted picture right after inserting it ActiveDocument.InlineShapes.AddPicture "C:\JPGs\Picture1.jpg" _ , LinkToFile:=False, SaveWithDocument:=True, Range:=ActiveDocument.Bookmarks("BMPicture1").Range 'Adds a bookmark to the inserted picture Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend With ActiveDocument.Bookmarks .Add Range:=Selection.Range, name:="BMPicture1x" .DefaultSorting = wdSortByName .ShowHidden = False End With When you are ready to delete the picture select the Picture bookmark and delete 'Selects and deletes the Bookmarked item Selection.GoTo What:=wdGoToBookmark, name:="BMPicture1x" Selection.Delete

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.