none
Deactivate Bookmark Ribbon button or not allow to delete existing bookmarks RRS feed

  • Question

  • I want to prevent the deletion of already existing bookmarks in the Word document. I thought of disabling the Bookmarks button in the Ribbon. Then users would not be able to modify, add or delete any bookmarks. The question is how can you disable the existing Bookmark button in the Ribbon.

    The better solution would be to have an event and prevent users from deleting existing bookmarks.

    Is there any possibility to handle this? (C#)


    • Edited by dermaga Tuesday, January 8, 2019 2:19 PM
    Tuesday, January 8, 2019 2:18 PM

All replies

  • Bookmarks can be deleted via a number of ways and not just by using the Bookmarks dialog. For instance, if text containing a bookmark is deleted then the bookmark is deleted - so you would need to protect the text to stop this method of deleting a bookmark. Also, there may be many invisible bookmarks in a document which are created by TOCs or Cross-Referencing - do you want them also preserved?

    I would be inclined to use the Group command on the bookmarked text to preserve both the bookmark and the text within it but that might not be what you want and you may have problems if bookmarks overlap.

    Can you explain why exactly it is important to preserve the bookmarks so we can suggest a workable solution. 

    Wednesday, January 9, 2019 4:48 AM
  • Thank you for response.

    I want to have protected text areas consisting of multiple lines of text - protected by password for no-admin users. I wanted to achieve this with bookmarks and with the event WindowSelectionChange to check every time when bookmark was clicked on -> protect document with password and for any other parts in the doc -> unprotect document. 

    Wednesday, January 9, 2019 11:51 AM
  • I don't think that is the best way. SelectionChange is too invasive and relies on the users enabling macros - it is very simple to just disable macros and your functionality is gone.

    Try protecting the content by using Content Controls. You can protect the text as well as stopping it from being deleted. If you want to use macros, there are entry and exit events which allow you to fiddle attributes of the CCs depending on the selection but that probably isn't going to be necessary once the CCs are protected.

    Thursday, January 10, 2019 5:00 AM
  • I already tried to protect Word content with Content Controls but it sometimes throws an exception "Failed Command" without any further information.
    • Edited by dermaga Thursday, January 10, 2019 10:29 AM
    Thursday, January 10, 2019 9:48 AM