View Full Version : Remove a particular bookmark from a group of word documents
I have a macro which removes all bookmarks from a single opened document. However, I wish to remove a particular bookmark, and from a group of documents. How can I do it ?
Macro as under:
Sub RemoveBkmk()
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
bkm.Delete
Next bkm
End Sub
Please help.
Addendum - Name of bookmark I wish to delete is 'bm1' .
gmayor
05-09-2016, 03:45 AM
To remove just the one bookmark
Sub RemoveBkmk()
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
If bkm.Name = "bm1" Then
bkm.Delete
Exit For
End If
Next bkm
End Sub
For a batch of documents, use the following http://www.gmayor.com/document_batch_processes.htm (http://www.gmayor.com/document_batch_processes.htm) to handle the files and folders and modify the above macro to enable it to be used as a custom process e.g.
Function RemoveBkmk(oDoc As Document) As Boolean
On Error GoTo err_handler
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
If bkm.Name = "bm1" Then
bkm.Delete
Exit For
End If
Next bkm
RemoveBkmk = True
lbl_Exit:
Exit Function
err_handler:
RemoveBkmk = False
Err.Clear
GoTo lbl_Exit
End Function
Thanks a million , sir ! Worked perfectly. May your tribe increase.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.