Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

2002: TOC

3 views
Skip to first unread message

JulieD

unread,
Mar 27, 2003, 6:06:54 AM3/27/03
to
Hi All

I have a document where i use code to generate the TOC based on title &
heading 1 style .. however, i would like the word "page" to appear next to
the page number in the toc - eg

title 1 ........................page 1
heading 1....................page 1
heading 1b..................page 2
etc

any ideas?

Regards
Julie

Heretic

unread,
Mar 31, 2003, 1:34:51 AM3/31/03
to
"JulieD" <ju...@hcts.net.au> was spinning this yarn:

G'day "JulieD" <ju...@hcts.net.au>,

Not possible unless you convert the TOC to static text and macro edit
it just prior to publishing.


Steve Hudson - Word Heretic, Sydney, Australia
I can do tricky stuff with Word or words for you.
her...@tdfa.com Ph: 612-9590-4344 / 614-2241-5965
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 1558 pages of dump left and dropping...

The VBA Beginner's Spellbook is now available!
The first graphical representation of the Word object model
and an extensive checklist for functional template development.
Perfect for everyone at every level of VBA usage.

Doug Robbins - Word MVP

unread,
Mar 31, 2003, 4:36:15 AM3/31/03
to
Hi Julie,

If you run a macro containing the following code while the document
containing the table of contents is the active document, it will create a
new document containing a "table of contents" with the word "page " inserted
before the number.

Dim TOC As Range, pagnum As Range, SourceDoc As Document, TOCDoc As
Document
Set SourceDoc = ActiveDocument
Set TOC = SourceDoc.TablesOfContents(1).Range
TOC.Copy
Set TOCDoc = Documents.Add
TOCDoc.Range.Paste
TOCDoc.Fields.Unlink
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(^t)([0-9]{1,}^13)"
.Replacement.Text = "\1Page \2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

I just noticed that you said you were using code to generate the table of
contents. If the above is not applicable to the result, post back to the
newsgroup with the code that you are using pasted into the message so that
we can see what it is doing and how it could be modified to give the desired
result.

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP
"JulieD" <ju...@hcts.net.au> wrote in message
news:uh3xLFF9...@TK2MSFTNGP12.phx.gbl...

JulieD

unread,
Mar 31, 2003, 7:55:32 AM3/31/03
to
Hi Doug

Thanks - I'll see if i can adapt your code for what i need ... however, i'm
guessing that everytime i rebuild the TOC (F9 - entire table option) i'm
going to have to rerun this code

Cheers
Julie

"Doug Robbins - Word MVP" <d...@mvps.org> wrote in message
news:udaM8j29...@TK2MSFTNGP12.phx.gbl...

0 new messages