Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting Excel Formatting over multiple files that exist in 1 folder

Status
Not open for further replies.

vadare7

IS-IT--Management
Sep 9, 2010
1
US
I'm thinking this shouldn't be this difficult... (but finding it to be so)

My vbs script produces data to 35 separate Excel Workbooks in a common folder. Each Workbook has a different name (account number -currentdate-.xls). I have written the script to format the workbooks (which works great individually) and am having difficulty in just how to have the script loop through each .xls file in the common folder to format the multiple workbooks.

Could anyone please assist / point me in the right direction? I have been working with different WMI options with no success. Do I get a file list and then pass that into another piece that executes the formatting section of my script??

Note that at the initial run of my script, I have the previous day files archived to a separate folder so that the Main folder will only hold the most current data for formatting.

Many Thanks
 
You can process all files in a given folder using code similar to this:
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\YourPath\YourFolder"

Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files

For Each objFile in colFiles

[COLOR=green]'process files here[/color]

Next

Wscript.Echo("Done Processing Files")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top