Hello. I am trying to create a macro that adds footnotes in a Word document when there is specific text. For example, I have a list of names and addresses with common occurring typos.
From the data, the text that I would want footnoted are “SMith”, “NEw”, “ORLeans”.
This is the code I have but it is not giving me what I want.
---
Public Sub HighlightMultipleWords()
Application.ScreenUpdating = False
Dim sArr() As String
Dim rTmp As Range
Dim x As Long
Set rTmp = ActiveDocument.Range
sArr = Split("SMith”, “NEw”, “ORLeans ")
For x = 0 To UBound(sArr)
With rTmp.Find
.Text = sArr(x)
.Replacement.Text = sArr(x)
ActiveDocument.Footnotes.Add rTmp, Text:="Written in data"
End With
Next
End Sub
---
Any help would be greatly appreciated. Thank you!
From the data, the text that I would want footnoted are “SMith”, “NEw”, “ORLeans”.
This is the code I have but it is not giving me what I want.
---
Public Sub HighlightMultipleWords()
Application.ScreenUpdating = False
Dim sArr() As String
Dim rTmp As Range
Dim x As Long
Set rTmp = ActiveDocument.Range
sArr = Split("SMith”, “NEw”, “ORLeans ")
For x = 0 To UBound(sArr)
With rTmp.Find
.Text = sArr(x)
.Replacement.Text = sArr(x)
ActiveDocument.Footnotes.Add rTmp, Text:="Written in data"
End With
Next
End Sub
---
Any help would be greatly appreciated. Thank you!