Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hyperlinks within document go to wrong place | Microsoft Word Help | |||
Footers | Microsoft Word Help | |||
Word automatically inserts page break when printing | Tables | |||
script language in header/footer | Page Layout | |||
Cross-referencing to page numbers | Page Layout |