ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBS for all xls in a folder (https://www.excelbanter.com/excel-programming/358329-vbs-all-xls-folder.html)

JavyD

VBS for all xls in a folder
 
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?

Tom Ogilvy

VBS for all xls in a folder
 
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.

--
Regards,
Tom Ogilvy



"JavyD" wrote:

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?



All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com