After exchanging a few PMs with ladracer, we came up with the following that works:
Code:
Sub JinjaSearch()
'A basic Word Macro coded by Gregory K. Maxey
Dim oDlg As FileDialog
Dim strFolder As String
Dim strFile As String
Dim strSrch() As String
Dim lngIndex As Long, lngFileIndex As Long
Dim oRng As Range
Dim lngCount As Long
Dim oDocMain As Document
Dim oTbl As Table
Dim oDocQuery As Document
'strSrch = Split("% if|% elif|% else|% endif|%p if|%p elif|%p else|%p endif", "|")
'strSrch = Split("% if|% endif|%p if|%p endif|%tr for|%tr endfor|%tc for|%tc endfor", "|")
strSrch = Split("% if|% endif|%p if|%p endif", "|")
Set oDocMain = ActiveDocument
Set oTbl = oDocMain.Tables(1)
Set oDlg = Application.FileDialog(msoFileDialogFolderPicker)
If oDlg.Show <> -1 Then Exit Sub
strFolder = oDlg.SelectedItems(1) & Application.PathSeparator
strFile = Dir(strFolder & "*.doc?")
While strFile <> ""
lngFileIndex = lngFileIndex + 1
oTbl.Rows.Add
Set oDocQuery = Documents.Open(FileName:=strFolder & strFile, _
ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
Format:=wdOpenFormatAuto, XMLTransform:="")
oTbl.Rows(lngFileIndex + 1).Cells(1).Range.Text = oDocQuery.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(lngFileIndex + 1).Cells(lngIndex + 2).Range.Text = lngCount
End With
Next lngIndex
oDocQuery.Close 0
strFile = Dir()
Wend
lbl_Exit:
Exit Sub
End Sub 