Deleting a graphic in a Header

A

Angie M.

Hello,

I have the following code that needs to go into the Header, go to the
bookmark which is a graphic that I created a bookmark for, and then delete
the graphic. When I do it manually it works fine but the macro returns an
error that says it cannot find the bookmark. What am I doing wrong?? Thanks
for any suggestions:

Selection.HomeKey Unit:=wdStory

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.GoTo What:=wdGoToBookmark, Name:="bkLogo"

Selection.ShapeRange.Delete
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
 
G

Greg Maxey

Hello,

I have the following code that needs to go into the Header, go to the
bookmark which is a graphic that I created a bookmark for, and then delete
the graphic. When I do it manually it works fine but the macro returns an
error that says it cannot find the bookmark. What am I doing wrong?? Thanks
for any suggestions:

Selection.HomeKey Unit:=wdStory

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.GoTo What:=wdGoToBookmark, Name:="bkLogo"

Selection.ShapeRange.Delete
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

I don't know why your code responds as you indicate. If you have
bookmark why don't you just use:

Sub Test()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("bkLogo").Range
oRng.Text = ""
ActiveDocument.Bookmarks.Add "Test", oRng
'or if you don't need to preserve the bookmark simply
'ActiveDocument.Bookmarks("bkLogo").Range.Delete
End Sub
 

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