removing all bookmarks at one time

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

removing all bookmarks at one time

Post by Deborahp »

Is there a way to remove all bookmarks at the same time?

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: removing all bookmarks at one time

Post by Rudi »

Hi Deborah,

Try the macros at this link. They have been confirmed to work fine!

Link: http://support.microsoft.com/kb/184041
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78857
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: removing all bookmarks at one time

Post by HansV »

For most situations, this simple macro will do:

Code: Select all

Sub RemoveBookmarks()
  Dim bmk As Bookmark
  For Each bmk In ActiveDocument.Bookmarks
    bmk.Delete
  Next bmk
End Sub
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: removing all bookmarks at one time

Post by Sundog »

Hans, my Word 2010 document has an Attachment with separate page numbering (that I learned how to do from the Lounge with PAGEREF arithmetic). After I remove all bookmarks, I need to insert a bookmark just prior to the last section break in the document, so the Attachment page numbering works. What code should I append to the RemoveBookmarks macro to accomplish this?

Something like: go to end of document, search up for section break, insert bookmark Att just ahead of section break.
Sundog

User avatar
HansV
Administrator
Posts: 78857
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: removing all bookmarks at one time

Post by HansV »

Does this do what you want?

Code: Select all

    Dim lngPos As Long
    Dim rng As Range
    lngPos = ActiveDocument.Sections(ActiveDocument.Sections.Count - 1).Range.End - 1
    Set rng = ActiveDocument.Range(lngPos, lngPos)
    ActiveDocument.Bookmarks.Add Name:="Att", Range:=rng
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: removing all bookmarks at one time

Post by Sundog »

Will try and report. Thanks.
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: removing all bookmarks at one time

Post by Sundog »

Works as advertised. Thanks again!
Sundog