Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2017, 07:10 AM
Slamzor Slamzor is offline Find {text} and insert cross reference from bookmark Windows 10 Find {text} and insert cross reference from bookmark Office 2016
Novice
Find {text} and insert cross reference from bookmark
 
Join Date: Dec 2017
Posts: 7
Slamzor is on a distinguished road
Default Find {text} and insert cross reference from bookmark

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
Reply With Quote
  #2  
Old 12-01-2017, 05:12 PM
macropod's Avatar
macropod macropod is offline Find {text} and insert cross reference from bookmark Windows 7 64bit Find {text} and insert cross reference from bookmark Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

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
Note: Your thread title refers to {text} but the post refers to [table]. The macro processes the latter.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find {text} and insert cross reference from bookmark Find word, Insert Paragraph and bookmark gattaca714 Word VBA 2 03-24-2017 09:23 PM
Find {text} and insert cross reference from bookmark Cross-reference does not maintain formatting from bookmark frannie Word 2 03-23-2017 04:33 PM
Find {text} and insert cross reference from bookmark Weird issue with bookmark and cross-reference Maddog32 Word 2 06-10-2016 02:39 PM
Find {text} and insert cross reference from bookmark Insert a cross-reference in a caption RomFigo Word 9 09-25-2015 12:32 AM
Find {text} and insert cross reference from bookmark Need help with using bookmark and cross-reference mpdsal Word 1 07-26-2012 01:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:46 PM.


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