View Single Post
 
Old 02-04-2013, 05:16 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I assume you're trying to populate the bookmarked range. In that case, instead of:
Code:
    With objWord
... 
    End With
try something along the lines of:
Code:
    With objDoc
        Dim wdRng As objWord.Range, StrBkMkNm As String
        StrBkMkNm = "MySpots"
        Set wdRng = .Bookmarks("MySpots").Range
         'Insert header (bookmark MySpot is in Header, Bookmark Myspots is in table in header, Bookmark MyReference is in normal text)
        .Fields.Add Range:=.Bookmarks(StrBkMkNm).Range, Type:=wdFieldEmpty, Text:="REF MyReference \*Charformat", PreserveFormatting:=False
        .Bookmarks.Add Range:=wdRng, Name:=StrBkMkNm
    End With
That said, is there a reason you can't use a pre-configured template, with the cross-references etc already in place? You might also consider using a unique Style for the source content and StyleRef field in the header instead of a REF field.

Note also that there is no need to 'seek' the header or to select anything.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote