Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word/OpenXML - How do I create a hidden bookmark?

I've not had any luck in either the OpenXML API or Word/VSTO API, finding a way to create or modify a bookmark's visibility. Even adding bookmarks manually in Word, there's no box to check to make the bookmark hidden. Although there is a checkbox in the Bookmarks dialog that lets you show hidden bookmarks. So how are hidden bookmarks represented in the XML, and can you create them using the Open XML SDK? Or are they a legacy thing that MS no longer wants us to create?

like image 357
System.Cats.Lol Avatar asked Mar 30 '11 13:03

System.Cats.Lol


1 Answers

OK so this is easier than I thought...you just precede the bookmark name with an underscore. Note that this can only be done programmatically, not when adding bookmarks manually in Word.

Iiiiiiiiinteresting....

Update: Another thing I found--before you can iterate or access hidden bookmarks in a Bookmarks object, you must set its ShowHidden property to true.

PS - SO, if you have any control over your spelling dictionary, you might add "programmatically". Unless I'm spelling it wrong. :)

like image 59
System.Cats.Lol Avatar answered Oct 04 '22 13:10

System.Cats.Lol