Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2019, 04:01 PM
jeffreybrown jeffreybrown is offline Create bookmarks, links, or references throught doc Windows Vista Create bookmarks, links, or references throught doc Office 2007
Expert
Create bookmarks, links, or references throught doc
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Create bookmarks, links, or references throught doc

What is the best way to create bookmarks, links, or references throughout a doc?



I have some VBA to extract the references throughout the document that I would like to reference.

Code:
Sub FindInsideParanthesis()
    Dim StrOut As String
    With ActiveDocument
      With .Range
        With .Find
          .Text = "\(*\)"
          .MatchWildcards = True
          .Execute
        End With
        Do While .Find.Found = True
          StrOut = StrOut & vbCr & .Text
          .Collapse wdCollapseEnd
          .Find.Execute
        Loop
      End With
      .Range.InsertAfter StrOut
    End With
End Sub
This will place the references at the end of the document with the parenthesis attached, but I will remove the parenthesis first. I manual setup some examples in this document, but would like to automate this process.
Attached Files
File Type: docx Test Doc.docx (17.5 KB, 8 views)
Reply With Quote
  #2  
Old 04-24-2019, 04:44 PM
macropod's Avatar
macropod macropod is offline Create bookmarks, links, or references throught doc Windows 7 64bit Create bookmarks, links, or references throught doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could, of course use an INDEX, in which case, you'd simply add XE fields at each of the found locations. For example:
Code:
Sub IndexParentheses()
Dim StrIdx As String
With ActiveDocument
  With .Range
    With .Find
      .Text = "\(*\)"
      .MatchWildcards = True
      .Execute
    End With
    Do While .Find.Found = True
      StrIdx = Replace(Replace(.Text, ")", Chr(34)), "(", Chr(34))
      .Collapse wdCollapseEnd
      .Fields.Add .Duplicate, wdFieldEmpty, "XE " & StrIdx, False
      .Find.Execute
    Loop
  End With
    .Indexes.Add Range:=.Range.Characters.Last, HeadingSeparator:=wdHeadingSeparatorNone, _
      Type:=wdIndexIndent, RightAlignPageNumbers:=True, NumberOfColumns:=1
End With
End Sub
No bookmarks or cross-references, per se, needed. The Index entries get sorted alphabetically and, if the same entry appears multiple times, grouped.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-25-2019, 04:11 PM
jeffreybrown jeffreybrown is offline Create bookmarks, links, or references throught doc Windows Vista Create bookmarks, links, or references throught doc Office 2007
Expert
Create bookmarks, links, or references throught doc
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Thanks Paul. This will work well.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create bookmarks, links, or references throught doc Is there a way to summarise all bookmarks and cross references used in a Word document? Training Word VBA 1 11-09-2017 12:06 AM
Where to put Subroutine to make sure bookmarks aren't deleted so cross-references work mrsjetset Word VBA 5 06-29-2016 05:06 PM
Create bookmarks, links, or references throught doc Bookmarks & cross-references Suchoklates Word 1 09-19-2013 02:32 AM
Links between files to bookmarks in PDF spud098 Word 0 07-14-2010 01:11 AM
Bookmarks with different figure references Dan_68 Word 0 02-15-2010 08:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft