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