- Oct 3, 2004
- 5,761
- 12
- 81
I need to make a macro that takes a folder of files and saves them as templates. Same file name.
This is what I have so far, based on some online research, but I haven't made any meaningful progress.
This is what I have so far, based on some online research, but I haven't made any meaningful progress.
Code:
Sub AllFiles()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "Q:\Temp (Mario)\Archive" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xls")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
ActiveWorkbook.SaveAs Filename:=Workbook, FileFormat:=xlTemplate, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub