Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
C Marshall
 
Posts: n/a
Default Page Reference Codes and Bookmarks or Styles

I'm doing a directory of attorney bios. There are 245 attorneys. I need to
create a TOC and an Index. The TOC is firstname/lastname/location in order
by specific sections and specific attorneys (partners 1st, etc.) The Index
will be by lastname,/first name.

I found some code to automatically bookmark a style. The names are
formatted with a style. Next I need to create the pageref codes. I have a
macro to list all the bookmark names.

Is there a way to automate creating the pageref code by either copying the
name from my bookmark list, then create a pageref code assigning the copied
bookmark name that was copied? Or is there a way to auto pageref each name
using the style?

I put together the code below, but doesn't work. I thought I could assign
the copied text to a variable, then assign the variable text to the page ref
code.

Sub PageReference_TEST()
'
' PageReference_TEST Macro
' Macro recorded 6/12/2006 by cm9125
'
Dim aText As String

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
Selection.HomeKey Unit:=wdLine

aText = Selection.Text

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"PAGEREF" & aText, PreserveFormatting:=True
Debug.Print aText
End Sub
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jezebel
 
Posts: n/a
Default Page Reference Codes and Bookmarks or Styles

You don't need to do any of this. You can create a TOC directly from any
styles you like (or from TC fields that you insert): either way, the page
numbers will be inserted automatically. Likewise, index entries also pick up
the page numbers automatically.


"C Marshall" wrote in message
...
I'm doing a directory of attorney bios. There are 245 attorneys. I need
to
create a TOC and an Index. The TOC is firstname/lastname/location in
order
by specific sections and specific attorneys (partners 1st, etc.) The
Index
will be by lastname,/first name.

I found some code to automatically bookmark a style. The names are
formatted with a style. Next I need to create the pageref codes. I have a
macro to list all the bookmark names.

Is there a way to automate creating the pageref code by either copying the
name from my bookmark list, then create a pageref code assigning the
copied
bookmark name that was copied? Or is there a way to auto pageref each
name
using the style?

I put together the code below, but doesn't work. I thought I could assign
the copied text to a variable, then assign the variable text to the page
ref
code.

Sub PageReference_TEST()
'
' PageReference_TEST Macro
' Macro recorded 6/12/2006 by cm9125
'
Dim aText As String

Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
Selection.HomeKey Unit:=wdLine

aText = Selection.Text

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"PAGEREF" & aText, PreserveFormatting:=True
Debug.Print aText
End Sub



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlinks within document go to wrong place Laura79 Microsoft Word Help 7 April 27th 06 04:21 PM
Footers John McC Microsoft Word Help 9 November 23rd 05 04:28 PM
Word automatically inserts page break when printing JBrooks Tables 7 May 18th 05 06:01 PM
script language in header/footer inadmissible3 Page Layout 12 May 4th 05 03:24 PM
Cross-referencing to page numbers Peyton Todd Page Layout 2 December 18th 04 03:57 AM


All times are GMT +1. The time now is 07:21 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"