You likely getting tired of me....I don't blame you.
I created a document with a bevy of rows and 9 columns.
I attempted to run the code you provided with a slight modification and it states:
Compile error: For Each may only iterate over a collection object or an array
Sub JinjaSearch()
'A basic Word Macro coded by Gregory K. Maxey
Dim strSrch() As String
Dim strFolder As String
Dim strFile As String
Dim lngIndex As Long
Dim oRng As Range
Dim lngCount As Long
Dim oDocMain As Document
Dim oDocQuery As Document
Set oDocMain = ActiveDocument
Set oTbl = oDocMain.Tables(1)
'Dim oTbl As Table
' Pop up input boxes for user to enter folder path, the finding and replacing texts.
strFolder = InputBox("Enter the folder path to the documents you want to change here:")
'For Each oDocQuery In strFolder
For Each oDocQuery In strFolder
Set oTbl = ActiveDocument.Tables(1)
strSrch = Split("% if|% elif|% else|% endif|%p if|%p elif|%p else|%p endif", "|")
oTbl.Rows(2).Cells(1).Range.Text = ActiveDocument.FullName
For lngIndex = 0 To UBound(strSrch)
lngCount = 0
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = strSrch(lngIndex)
While .Execute
lngCount = lngCount + 1
oRng.Collapse wdCollapseEnd
Wend
oTbl.Rows(2).Cells(lngIndex + 2).Range.Text = lngCount
End With
Next
Next oDocQuery
lbl_Exit:
Exit Sub
End Sub
Where did I go wrong this time?
|