Exclude hidden text from search?
One last issue and it done! Many of the MsWord Documents I need to search contain Hidden text. I need to exclude the hidden text from the word search. I have attempted everything I can to no avail. Could you give me a lead or better yet reply with a code lines to do the job, please!
Here is what I have developed and it works nicely. However
Dim fs As Object
Set fs = Application.FileSearch
Dim MyColumn As Integer
Dim MyColumn2 As Integer
Dim SearchWord As String
Dim SearchFile As String
Dim MyPosition As Integer
Dim c As Object
Dim SearchRow As Integer
MyRow = Range("A1").Value
MyColumn2 = Range("A3").Value 'Contains the formula column() so the program knows what the last column is
With ActiveSheet
Range("A3").Select ‘Selects first row, column “A” above the Searchfile list
MyColumn = 0
With fs
Do While MyColumn < MyColumn2 - 2 'This loops through all the SearchWords in row 2, beginning at column “B”
MyColumn = MyColumn + 2
SearchWord = Range(Cells(2, MyColumn), Cells(2, MyColumn)).Value
Do While ActiveCell.Row < MyRow - 2 'This loop goes thru the file list in column A
ActiveCell.Offset(1, 0).Select
SearchFile = ActiveCell.Value
If SearchFile = "" Or IsEmpty(SearchFile) = True Then
Else
.NewSearch
.LookIn = SearchPath ‘SearchPath is provided by the Explorer browser
.SearchSubFolders = True
.TextOrProperty = SearchWord
.MatchAllWordForms = True
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To fs.FoundFiles.Count
MyPosition = InStr(1, fs.FoundFiles(i), SearchFile, 1)
If MyPosition > 0 Then 'If the Search file (which is the file name listed in column A is found _
in the array of files containing the Searchword then its position _
within the string will be greater than 0 and therefore it exists as a _
part of the arrray
With Range(Cells(4, 1), Cells(MyRow - 1, 1)) 'Address of the file list on the worksheet
Set c = .Find(SearchFile, LookIn:=xlValues)
If Not c Is Nothing Then
SearchRow = c.Row
Range(Cells(SearchRow, MyColumn), Cells(SearchRow, MyColumn)).Value = 1
End If
End With
End If
Next
End If
Loop
Range("A3").Select
Loop
End With
End With