VBS for all xls in a folder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, how can I have three vbs that I have, run all on excel files in a
folder. 1 vbs formats the file, the other subtotals it, and the other
freezes the panes. I'm going to merge them all, but I want the vbs to run
for all xl files in the folder, not for just C:\test.xls is this possible?
 
Sub ProcessAll()
Dim s as String
Dim f as String
f = "C:\My Folder\"
s = Dir(f & "*.xls")
do while s <> ""
set bk = workbooks.Open(f & s)
' process the workbook
bk.Close Savechanges:=True
s = dir()
Loop
end Sub

is one approach.
 
Back
Top