Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-12-2019, 03:43 PM
macropod's Avatar
macropod macropod is offline How to find if a word is part of a cross-reference by vba Windows 7 64bit How to find if a word is part of a cross-reference by vba Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,366
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

Why not simply loop through all the cross-references? For example:
Code:
Sub Demo()
Dim Fld As Field, StrWrd As String
StrWrd = InputBox("Input the string to find")
With ActiveDocument
  For Each Fld In .Fields
    With Fld
      If .Type = wdFieldRef Then
        If InStr(.Result, StrWrd) > 0 Then
          MsgBox StrWrd & " can be found in a field"
          Exit Sub
        End If
      End If
    End With
  Next
End With
End Sub
There are also far more efficient ways of finding coloured text...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
cross-reference, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find if a word is part of a cross-reference by vba Find instances of heading text in the body of my doc, make cross reference to the actual heading MAHE Word VBA 4 03-03-2018 07:59 AM
How to find if a word is part of a cross-reference by vba Find {text} and insert cross reference from bookmark Slamzor Word VBA 1 12-01-2017 05:12 PM
How to find if a word is part of a cross-reference by vba Cross reference with pages in word ? nospamdav999 Word 5 05-13-2017 03:43 AM
How to find if a word is part of a cross-reference by vba Reference number and cross reference for equation numbers to match the thesis format wmac Word 1 05-14-2013 08:54 PM
Cross reference issues with word to PDF rammrunal Word 0 07-17-2012 05:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:22 PM.


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