How to Delete Hidden and Corrupted Bookmarks in Word Using a VBA Macro
Question details
The user needs to remove persistent visible and hidden bookmarks that may cause document corruption, typically left behind by old content or copied web snippets.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Cleaning up a large Word document where standard bookmark deletion attempts fail, leading to potential document corruption.
- Observed behavior
- Visible and hidden bookmarks remain in the document despite manual deletion attempts, making the file behave as if it is corrupted.
Always save a backup copy of your document before running macros or performing bulk deletions to prevent accidental loss of important formatting or data.
Use a VBA Macro to Delete All Bookmarks
The most effective way to remove persistent bookmarks is by running a simple VBA script that iterates through and deletes both visible and hidden bookmarks.
Before running the macro, it is highly recommended to enable the display of hidden bookmarks. This ensures the macro successfully identifies and removes every bookmark instance.
In Word, go to File > Options > Advanced. Scroll down to the 'Show document content' section, check the box for 'Show bookmarks', and click OK.
Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications (VBA) window.
Click Insert > Module from the top menu, and paste the following code into the blank window: Sub DeleteAllBookmarksInDoc() Dim lngIndex As Long For lngIndex = ActiveDocument.Bookmarks.Count To 1 Step -1 ActiveDocument.Bookmarks(lngIndex).Delete Next lngIndex End Sub
Press F5 or click the Run button (green play icon) in the toolbar to execute the macro. Once finished, save and reopen the document to confirm all bookmarks are gone.

Copy Document Content to a New File
If the document is corrupted and the macro fails, copying the contents without the final paragraph mark can leave the corruption behind.
Easily Manage and Delete Bookmarks in WPS Office
WPS Writer provides a user-friendly, lightweight interface to visually manage, locate, and delete bookmarks without needing to write complex VBA macros.
- 1. Open your document: Launch WPS Writer and open the document containing the unwanted bookmarks.
- 2. Access the Bookmark manager: Navigate to the Insert tab on the top ribbon and click on Bookmark.
- 3. Select unwanted bookmarks: Review the list of bookmarks found in the document. You can easily spot automatically generated or corrupted entries.
- 4. Delete and save: Select the bookmarks you wish to remove, click the Delete button, and save your document.

Frequently Asked Questions
Why do hidden bookmarks appear in my Word document?
Hidden bookmarks are often automatically generated when you copy and paste content from web pages, insert cross-references, or generate a Table of Contents.
Will deleting all bookmarks break my Table of Contents?
Yes, deleting all bookmarks may affect your Table of Contents or cross-references, as these features rely on hidden bookmarks to link to specific headings. You will likely need to update or rebuild the TOC after running the macro.
Why should I copy everything except the final paragraph mark?
The final paragraph mark in a Word document acts as a container for much of the document's hidden background data and layout formatting. Excluding it when copying to a new document can strip away underlying corruptions.
Can saving the document as an RTF or PDF fix the corruption?
Converting to RTF or using PDF and OCR might remove the corrupted bookmarks, but these methods frequently damage your document's original formatting, headings, and image placements.




