Is it possible to programmatically make all bookmarks in the Bookmarks collection editable (WdEditorType.wdEditorEveryone)? I know how to do it one-by-one, but I'm going to need to work with a collection of an unknown number of bookmarks and unknown bookmark names. For example, one document may have: MyBookmark1 MyBookmark15 MyBookmark33 Another document may have: MyBookmark44 And another document may not have any bookmarks at all. But all existing bookmarks will be in the format: MyBookmarkNN Any and all help is greatly appreciated. Thanks, Rich
Rich Hutchins was telling us: Rich Hutchins nous racontait que : > Is it possible to programmatically make all bookmarks in the Bookmarks > collection editable (WdEditorType.wdEditorEveryone)? I know how to do > it one-by-one, but I'm going to need to work with a collection of an > unknown number of bookmarks and unknown bookmark names. For example, > one document may have: > > MyBookmark1 > MyBookmark15 > MyBookmark33 > > Another document may have: > > MyBookmark44 > > And another document may not have any bookmarks at all. But all > existing bookmarks will be in the format: MyBookmarkNN > > Any and all help is greatly appreciated. Here's one way to access all the bookmarks: Dim bkmDocument As Bookmarks Dim i As Long Set bkmDocument = ActiveDocument.Bookmarks For i = 1 To bkmDocument.Count 'your code, e.g.: bkmDocument(i).Range.Font = "Arial" Next -- Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
I don't really know what you mean, but to do something to all of the bookmarks in a document, you could use Dim i as Long For i = ActiveDocument.Bookmarks.Count to 1 Step -1 With ActiveDocument.Bookmarks(i) .DoWhateverYouWant End With Next i -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Rich Hutchins" wrote in message news:87530B80-6357-433D-9E20-11B44AB063CF@microsoft.com... > Is it possible to programmatically make all bookmarks in the Bookmarks > collection editable (WdEditorType.wdEditorEveryone)? I know how to do it > one-by-one, but I'm going to need to work with a collection of an unknown > number of bookmarks and unknown bookmark names. For example, one document > may > have: > > MyBookmark1 > MyBookmark15 > MyBookmark33 > > Another document may have: > > MyBookmark44 > > And another document may not have any bookmarks at all. But all existing > bookmarks will be in the format: MyBookmarkNN > > Any and all help is greatly appreciated. > > Thanks, > Rich
Thank you Doug and Jean-Guy for your responses. About the same time you posted your suggestions, I got the following code to do what I need it to do (at least on the surface it appears to do what I need it to do since I no longer have any problems editing user-added bookmarks): Dim bkMark As Bookmark For Each bkMark In ActiveDocument.Bookmarks bkMark.Range.Editors.Add (Word.WdEditorType.wdEditorEveryone) Next bkMark As usual, one of the many ways to solve the problem so I _think_ I'm OK with this solution. I need to try to abuse it like a user would, but I think it'll survive. Thanks again for taking the time. Rich "Doug Robbins - Word MVP" wrote: > I don't really know what you mean, but to do something to all of the > bookmarks in a document, you could use > > Dim i as Long > For i = ActiveDocument.Bookmarks.Count to 1 Step -1 > With ActiveDocument.Bookmarks(i) > .DoWhateverYouWant > End With > Next i > > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP > > "Rich Hutchins" wrote in message > news:87530B80-6357-433D-9E20-11B44AB063CF@microsoft.com... > > Is it possible to programmatically make all bookmarks in the Bookmarks > > collection editable (WdEditorType.wdEditorEveryone)? I know how to do it > > one-by-one, but I'm going to need to work with a collection of an unknown > > number of bookmarks and unknown bookmark names. For example, one document > > may > > have: > > > > MyBookmark1 > > MyBookmark15 > > MyBookmark33 > > > > Another document may have: > > > > MyBookmark44 > > > > And another document may not have any bookmarks at all. But all existing > > bookmarks will be in the format: MyBookmarkNN > > > > Any and all help is greatly appreciated. > > > > Thanks, > > Rich > > >