I'm not sure whats wrong with this code.. but its not opening a file, when i run it, i do not get any errors, but nothing happens... i have checked the file names to make sure it matches the code, but still nothing
Code:
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Dim objFSO, objFile, objHTMLFile , objShell
Dim strLine, strSearchFile, strPath, strLogFile, strFileItemPath
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strSearchFile = "F:\Downloads\Facetcoat log files WORK\SearchString.txt" ' Set the Search File Path
strPath = "F:\Downloads\Facetcoat log files WORK\Network Drive Folder" ' A Path to a Folder where you want to look in
strLogFile = "F:\Downloads\Facetcoat log files WORK\Results.html"
If objFSO.FileExists(strSearchFile) Then
Set objFile = objFSO.OpenTextFile(strSearchFile,ForReading) ' Open the File to read from
' if you want to log this activity then include the next line
' Set objHTMLFile = objFSO.OpenTextFile(strLogFile, ForWriting, true) ' Create/overwrite the Log File
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine ' read file
if lcase(objFSO.GetExtensionName(strLine)) = "xls" then
strFileItemPath = strPath & "\" & strLine
if objFSO.FileExists(strFileItemPath) then ' checks to see if file is present
objShell.Run Chr(34) & strFileItemPath & Chr(34), 1, False ' starts the file and does NOT wait to continue
' if you want to log this activity then include the next line (remove comment character)
' objHTMLFile.WriteLine "<P><a href=""" & strFileItemPath & """>" & strFileItemPath & "</a></P>"
end if
end if
Loop
objFile.Close
Set objFile = Nothing
Else
WScript.Quit
End If