How to jump to a bookmark in a pagefooter

R

Rudy

I can't seem to jump to a bookmark in a footer.

I have to jump to a certain place in the footer, and a bookmark will be a fine way to place the text, I want to insert right there.

Can anybody help me to find the way to place the cursor at that specific point by using bookmarks?
 
H

Helmut Weber

Hi Rudy,
how about that:
Dim oSTr As Object
For Each oSTr In ActiveDocument.StoryRanges
On Error Resume Next
oSTr.Bookmarks("Book").Select
Next
There may be other ways to do that.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
R

Rudy

Hi Helmu

Thanks for the answer, but I did'nt explain properly, what I am about to do. You see, I have a template, in which footer I would like to place several variables from a database. I've placed some bookmarks in the footer, and I will then place the variables by these bookmarks

I don't see, how your code can do that, or???

/Rud

----- Helmut Weber skrev: ----

Hi Rudy
how about that
Dim oSTr As Objec
For Each oSTr In ActiveDocument.StoryRange
On Error Resume Nex
oSTr.Bookmarks("Book").Selec
Nex
There may be other ways to do that
Greetings from Bavaria, German
Helmut Webe
"red.sys" & chr$(64) & "t-online.de
Word 97, NT 4.
 
H

Helmut Weber

Hi Rudy,
like that:
oSTr.Bookmarks("Book").Range.Text = "text"
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
H

Helmut Weber

.... and in addition,
I was assuming, that you didn't know, in which
storyrange your bookmark("Book") resides. If you
exactly know, what bookmarks are where, and still
better, what index-number or index-name was assigned
to each bookmark, then, of course, looping through all
the stroyranges is unnecessarily complicated.
Helmut Weber
 
G

Graham Mayor

Footers are transient entities appearing on several pages, and not part of
the document text plane. I would be very surprised if you could access a
bookmark in a footer - even with the footer view open.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
H

Helmut Weber

Hi Graham,
nevertheless, the following code works properly:
Dim oSTr As Object
For Each oSTr In ActiveDocument.StoryRanges
If oSTr.Bookmarks.Exists("Book") Then
oSTr.Bookmarks("Book").Range.text = "Testing"
End If
Next
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
 
J

JGM

Hi Rudy,

And to add to Helmut's idea...

Define your bookmark with some content when you create it, one character
will be enough.

Then use this code to replace the content of the bookamrk and save the
bookmark so you can re-run the code as often as you want without losing the
bookamrk and always replacing the previous content by new content:

'_______________________________________
Dim oSTr As Object
Dim MyRange As Range

For Each oSTr In ActiveDocument.StoryRanges
If oSTr.Bookmarks.Exists("Book") Then
Set MyRange = oSTr.Bookmarks("Book").Range
'Here you should have a string variable instead of "Hello"
MyRange.Text = "Hello"
MyRange.Bookmarks.Add "Book", MyRange
End If
Next
'_______________________________________

HTH
Cheers!
 

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