Access bookmark in header

P

Pat Hartman (MVP)

I am trying to automate word from Access and I can't seem to get the syntax
correct for referencing a bookmark in the header.

WordApp.Selection.GoTo What:=wdGoToBookmark, Name:="CycleName"
WordApp.Selection.TypeText Text:=rsDAO!CycleName
works fine in the body of the document but can't "see" bookmarks in the
header. So I tried:

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
WordApp.Selection.GoTo What:=wdGoToBookmark, Name:="CycleName"
WordApp.Selection.TypeText Text:=rsDAO!CycleName

But that didn't work either. I still got the "Word cannot find the
requested bookmark" message.

Can someone point me in the right direction?
 
P

Pat Hartman (MVP)

Thanks anyway. I found a solution:

Dim rng As Word.Range
Dim bkm As String
bkm = "Cycle"
Set rng = WordDoc.Bookmarks(bkm).Range
rng.Text = rsDAO!CycleRoman
WordDoc.Bookmarks.Add bkm, rng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top