December 7th, 2011 09:31 AM
[RESOLVED] Using a VBscript to open up files in a folder
I am trying to build a VB script which will loop through a folder and open up all the files within it (all .xlsm). The code will then run a macro within each of the files.
It was working when the script was built as a list, but this was for a quick test, in real life it will deal with hundreds so a loop is needed.
the code i currently have is:
Dim FSO, FLD, FIL, objExcel
Set objExcel = CreateObject("Excel.application")
strFolder = "H:\My Documents"
Set FSO = CreateObject ("Scripting.FileSystemObject")
Set FLD = FSO.GetFolder (strFolder)
For Each FIL in FLD.Files
The script is running and then failing saying Error: 'Filename.xlsm' Could not be found. Which is strange, as it is there, and it has obviously found it as it is the first file in the folder.
I am unsure of where to go and what to do next.
Any help would be greatly appreciated.
Tags for this Thread
Click Here to Expand Forum to Full Width