#1
|
|||
|
|||
Add a bookmark to the Header using Word VBA
Its easy to add a bookmark to the header where there is a range to add it to, eg:
ActiveDocument.Bookmarks.Add name:="MyBookmark", Range:=ActiveDocument.Sections(1).Headers(wdHeader FooterPrimary).range.Paragraphs(1).Range But how do you set the bookmark to be at the beginning of the header with no range enclosed, ie just the I-beam shape I where the bookmark does not enclose anything. Can this be done without using the selection object? It sounds easy but I dont see a way to do it. Any ideas? Thanks Chris |
#2
|
||||
|
||||
Try:
Code:
Dim Rng As Range With ActiveDocument Set Rng = .Sections(1).Headers(wdHeaderFooterPrimary).Range Rng.Collapse wdCollapseStart .Bookmarks.Add Name:="MyBookmark", Range:=Rng End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks Paul
That works a treat. Inserting a bookmark was a general idea and I wanted to make it work for inserting autotext without damaging the header and your code works the same there: Dim Rng As Range Set Rng = ActiveDocument.Sections(1).Headers(wdHeaderFooterP rimary).Range Rng.Collapse wdCollapseStart ThisDocument.AttachedTemplate.AutoTextEntries("_Cl assificationStatus").Insert RichText:=True, where:=Rng Thanks again Chris. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word | marksm33 | Word VBA | 3 | 01-15-2015 07:55 PM |
Getting mult resps. selected in listbox to concatenate & paste at a bookmark in Word | marksm33 | Word VBA | 3 | 01-15-2015 05:59 PM |
Adding field in word in header in a bookmark in table with Excel vba Late Binding | Hdr | Excel Programming | 6 | 02-11-2013 02:58 AM |
Open header to insert text into bookmark | Amapola188 | Word VBA | 3 | 07-12-2012 05:16 PM |
[Word 2007] How to hyperlink directly another word file chapter/paragraph/bookmark? | LeeFX | Word | 4 | 05-05-2011 05:53 PM |