![]() |
|
#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] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
gattaca714 | Word VBA | 2 | 03-24-2017 09:23 PM |
![]() |
frannie | Word | 2 | 03-23-2017 04:33 PM |
![]() |
Maddog32 | Word | 2 | 06-10-2016 02:39 PM |
![]() |
RomFigo | Word | 9 | 09-25-2015 12:32 AM |
![]() |
mpdsal | Word | 1 | 07-26-2012 01:05 PM |