JuniperGreen
Member
Having become unstuck with a script I am working on I would appreciate some help. Basically, it reads in the string content of each file in a directory into an array (period delimited). It then searches for a keyword and if found concatenates each sentence in which it is found. The echoed output shows what was found in each file.
This works perfectly well and does what I want but in the 3rd last line of the piece of code shown below where I have "File OutPut:" I would like to have the actual name of the file instead. I have tried every which way to achieve this but without success. Although I think it is to do with "Object Required" I'm not sure how to resolve it.
I would be grateful if someone could point me in the right direction.
Thank you
This works perfectly well and does what I want but in the 3rd last line of the piece of code shown below where I have "File OutPut:" I would like to have the actual name of the file instead. I have tried every which way to achieve this but without success. Although I think it is to do with "Object Required" I'm not sure how to resolve it.
I would be grateful if someone could point me in the right direction.
Thank you
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set folder = objFSO.GetFolder(strFilePath)
for each file in folder.Files
Set objfile = objFSO.OpenTextFile(file.path, ForReading)
strContents = objfile.readAll
'Load String Into Array
outputArray = split(strContents,".")
'Check For KeyWord Match
for each strCurrentLine in outputArray
If InStr(strCurrentLine, strKeyWord) Then
'Concatenate Matches
strOutput = strOutput & "File OutPut: " & vbCRLF & strCurrentLine & "." & vbCRLF & vbCRLF
End if
next