![]() |
|
|
|
#1
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Thanks Paul. This will work well.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |