Deleting Selected Bookmarks - MS Word

jl123

New Member
Joined
Mar 3, 2009
Messages
2
Hi,

I'm trying to create a macro delete to delete bookmarks from word. I'm pretty new to this but I found a macro (below) that deletes all bookmarks from a page and 1 that deletes an individual bookmark. What I'm looking to do is delete certain selected ones.

ex. bookmark1
bookmark2
bookmark3
bookmark4

I would want to highlight and delete bookmark 1 and 4.

Here's what I have so far. I'm sure this just needs to be tweeked abit.

Sub Delete_Bookmarks()
Dim Selected_Bookmark As Bookmark
ActiveDocument.Bookmarks.ShowHidden = True
If ActiveDocument.Bookmarks.Count >= 1 Then
For Each Selected_Bookmark In ActiveDocument.Bookmarks
Selected_Bookmark.Delete
Next Selected_Bookmark

End If
End Sub

Here is also another that deletes a single selected bookmark.

Sub DelBookmarks_individually()


For n = 1 To Selection.Bookmarks.Count
Selection.Bookmarks(n).Delete
Next n
End Sub

Any help would be appreciated. I tried to search but didn't find what I was looking for.
 
In my experience, most 'custom written software' that uses bookmarks doesn't actually update the bookmarks - it just inserts something after them. If your's is anything like that, deleting the bookmarked range once the report has been generated isn't going to help.

You can confirm what's happening by pressing F5 in a report, choosing 'Bookmark' then selecting your 'Area' bookmark. If all of the text that was inserted there doesn't get highlighted, the software is only inserting the text after the bookmark.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,225,624
Messages
6,186,068
Members
453,336
Latest member
Excelnoob223

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top