Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Mar 2006
    Location
    Augusta, Maine
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cross-references Word 2003 (Word 2003)

    Can cross-references be printed with document in Word 2003? Have looked everywhere I know to look, can't find answer. Thanks.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Cross-references Word 2003 (Word 2003)

    I don't use cross-references, but there appear to be many kinds. If they could be printed, what would be the desired manner of display?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Cross-references Word 2003 (Word 2003)

    I found a question about it in the newsgroups, but that was yours... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    There is no built-in functionality for printing cross references.

    You could tick the 'Field codes' check box in the Print tab of Tools | Options. This will cause ALL field codes to be printed, including cross references. Unfortunately, they look like this:

    { REF _Ref141108623 h }

    so that is pretty useless. This also means that it won't be easy to create code to print the cross references.

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Cross-references Word 2003 (Word 2003)

    Hello Linda,

    As you probably know, any cross reference refers to a bookmark. You can make use of this fact to extract the cross reference details.

    The following macro generates a list of all bookmarks at the end of the active document, and displays their contents:
    Sub ListBkMrks()
    Dim oBkMrk As Bookmark, oBmk As Variant
    If ActiveDocument.Bookmarks.Count > 0 Then
    For Each oBkMrk In ActiveDocument.Bookmarks
    With Selection
    .EndKey Unit:=wdStory
    .InsertAfter vbCrLf
    .InsertAfter oBkMrk.Name & " "
    .EndKey Unit:=wdStory
    oBmk = ActiveDocument.Fields.Add(Range:=Selection.Range, _
    Text:= oBkMrk.Name, PreserveFormatting:=False) ' Note: Don
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cross-references Word 2003 (Word 2003)

    Thanks Macropod.
    I've created a similar Sub to list all Bookmarks. But in a document that also contains FormFields, these FF's are also listed. I tried to figure out a (not too complicated) way to distinguish between FF's and 'real' Bookmarks, but didn't succeed yet. Any ideas?

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Cross-references Word 2003 (Word 2003)

    I'm not macropod, but... A little object sniffing with the Locals window reveals the following.

    A regular bookmark will have:

    bookmarkobject.Range.FormFields.Count = 0

    while a FormField will have:

    bookmarkobject.Range.FormFields.Count = 1

    So you could test that before adding to your list.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Cross-references Word 2003 (Word 2003)

    It's not watertight, but the following may help.

    Dim bmk As Bookmark
    Dim blnFF As Boolean
    For Each bmk In ActiveDocument.Bookmarks
    blnFF = False
    If bmk.Range.Fields.Count > 0 Then
    Select Case bmk.Range.Fields(1).Type
    Case wdFieldFormCheckBox, wdFieldFormDropDown, wdFieldFormTextInput
    blnFF = True
    End Select
    End If
    If blnFF Then
    MsgBox bmk.Name & " belongs to a form field"
    Else
    MsgBox bmk.Name & " is another type of bookmark"
    End If
    Next bmk

    The code will return an incorrect result if you created a "real" bookmark whose range includes a form field.

  8. #8
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cross-references Word 2003 (Word 2003)

    Thank you both for your suggestions!

  9. #9
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cross-references Word 2003 (Word 2003)

    This Sub integrates macropod's and Hans' code, putting a label "FF" or "BM" at the start of each line.

    <pre>Sub ListAllBookmarks()
    'Based on code from macropod [Post 587,702] & HansV [Post 587,741] in Woody's Lounge
    Dim oBkMrk As Bookmark
    Dim oBmk As Variant
    Dim strLbl As String

    If Documents.Count < 1 Then Exit Sub
    If ActiveDocument.Bookmarks.Count > 0 Then
    'If document is protected then unprotect
    For Each oBkMrk In ActiveDocument.Bookmarks
    strLbl = "BM:" & " "
    If oBkMrk.Range.Fields.Count > 0 Then
    Select Case oBkMrk.Range.Fields(1).Type
    Case wdFieldFormCheckBox, wdFieldFormDropDown, wdFieldFormTextInput
    strLbl = "FF: " & " "
    End Select
    End If
    With Selection
    .EndKey Unit:=wdStory
    .InsertAfter vbCrLf
    .InsertAfter strLbl & oBkMrk.Name & " "
    .EndKey Unit:=wdStory
    oBmk = ActiveDocument.Fields.add(Range:=.Range, _
    text:=oBkMrk.Name, PreserveFormatting:=False)
    End With
    Next oBkMrk
    '(Re)protect document if necessary
    End If
    End Sub
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •