![]() |
|
#1
|
|||
|
|||
|
Hi. I have text that contains the word [table]. I want to replace this word with a cross-reference from a bookmark whose name is Table_1. Next replacement: [table] = Table_2 ... etc |
|
#2
|
||||
|
||||
|
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[table]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
i = i + 1
.Fields.Add Range:=.Duplicate, Type:=wdFieldEmpty, Text:="REF Table_" & i, PreserveFormatting:=False
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
MsgBox i & " table cross-references created."
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find word, Insert Paragraph and bookmark
|
gattaca714 | Word VBA | 2 | 03-24-2017 09:23 PM |
Cross-reference does not maintain formatting from bookmark
|
frannie | Word | 2 | 03-23-2017 04:33 PM |
Weird issue with bookmark and cross-reference
|
Maddog32 | Word | 2 | 06-10-2016 02:39 PM |
Insert a cross-reference in a caption
|
RomFigo | Word | 9 | 09-25-2015 12:32 AM |
Need help with using bookmark and cross-reference
|
mpdsal | Word | 1 | 07-26-2012 01:05 PM |