logo
search
VBA & Macro Problems

How to Delete Hidden and Corrupted Bookmarks in Word Using a VBA Macro

Huda QurayshiHuda Qurayshi Sep 30, 2026 868 views

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.

How to Delete Hidden and Corrupted Bookmarks in Word Using a VBA Macro
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.
Before you start

Always save a backup copy of your document before running macros or performing bulk deletions to prevent accidental loss of important formatting or data.

Solution 1Recommended

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.

1
Enable hidden bookmarks

In Word, go to File > Options > Advanced. Scroll down to the 'Show document content' section, check the box for 'Show bookmarks', and click OK.

2
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications (VBA) window.

3
Insert a new module

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

4
Run the macro

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.

Use a VBA Macro to Delete All Bookmarks
Verify Hidden Bookmarks: If some bookmarks persist, try saving and reopening the document after enabling the display of hidden bookmarks, then run the macro again.

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. 1. Open your document: Launch WPS Writer and open the document containing the unwanted bookmarks.
  2. 2. Access the Bookmark manager: Navigate to the Insert tab on the top ribbon and click on Bookmark.
  3. 3. Select unwanted bookmarks: Review the list of bookmarks found in the document. You can easily spot automatically generated or corrupted entries.
  4. 4. Delete and save: Select the bookmarks you wish to remove, click the Delete button, and save your document.
Fully compatible with Microsoft Word (.docx) formats and bookmark structuresIntuitive, visual Bookmark manager to quickly delete unwanted tagsLightweight and stable performance, even when handling large documents with web snippets
microsoft office alternative - wps office

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.