Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-12-2019, 02:58 PM
scienceguy scienceguy is offline How to find if a word is part of a cross-reference by vba Windows 10 How to find if a word is part of a cross-reference by vba Office 2016
Advanced Beginner
How to find if a word is part of a cross-reference by vba
 
Join Date: Feb 2019
Posts: 46
scienceguy is on a distinguished road
Default How to find if a word is part of a cross-reference by vba

Hello,



I need to write a VBA macro that will determine if a word is part of a cross-reference. I am doing this on multiple documents. I wrote a simple macro that goes word by word and finds all that have a blue font as a test case, to convince myself I can get the words. Now, I'd like to know if that word is associated with a cross-reference. Here is the code I have so far:

Code:
Sub BatchFindCR()
  
  Dim objDoc As Document
  Dim objSingleWord As Range
  Dim strFile As String, strFolder As String
 
  strFolder = "C:\Users\roy\Desktop\test files\"
  strFile = Dir(strFolder & "*.docx", vbNormal)
 
  While strFile <> ""
  Set objDoc = Documents.Open(FileName:=strFolder & strFile)
 
  For Each objSingleWord In objDoc.Words
    If objSingleWord.Font.ColorIndex = wdBlue Then
        MsgBox "Found: " & strFile
        Exit For
    End If
    'is word part of a cross-reference?
        'code
     
   '
    
  Next objSingleWord
 
  objDoc.Save
  objDoc.Close
  strFile = Dir()
  Wend
  
  MsgBox "Done!"
  
End Sub
Can someone help me get going, please?

Thanks,
Roy

Last edited by macropod; 02-12-2019 at 03:34 PM. Reason: Added code tags
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 08:13 AM.


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