Hi there.
I am using Excel 2007.
I have a template file (.XLTM) that I want to distribute to various users. My goal is for them to launch the file and be immediately prompted to save it as an XLSM file.
I've experimented with placing various code into the This Workbook module of my template file. Here's what I have currently:
Code:
Private Sub Workbook_Open()
Dim fNameAndPath As Variant
fNameAndPath = Application.GetSaveAsFilename(initialFilename:="", FileFilter:="Excel Files (*.XLSM), *.XLSM", Title:="Save As")
If fNameAndPath = False Then Exit Sub
Me.SaveAs Filename:=fNameAndPath
End Sub
It works perfectly. Here's the rub: upon opening the resulting XLSM file (i.e. the file that was saved upon opening the XLTM template), that too contains the same code and prompts the user to save as again. So my goal is for this code to run only in the initial template and not in the resulting files saved from the template. I hope I've explained that well.
An important point: my template contains a multitude of other code that I will want the saved XLSM files to still contain. I want to eliminate only the code abpove from resulting XLSM files.
Any advice would be most appreciated.
Thanks!
I am using Excel 2007.
I have a template file (.XLTM) that I want to distribute to various users. My goal is for them to launch the file and be immediately prompted to save it as an XLSM file.
I've experimented with placing various code into the This Workbook module of my template file. Here's what I have currently:
Code:
Private Sub Workbook_Open()
Dim fNameAndPath As Variant
fNameAndPath = Application.GetSaveAsFilename(initialFilename:="", FileFilter:="Excel Files (*.XLSM), *.XLSM", Title:="Save As")
If fNameAndPath = False Then Exit Sub
Me.SaveAs Filename:=fNameAndPath
End Sub
It works perfectly. Here's the rub: upon opening the resulting XLSM file (i.e. the file that was saved upon opening the XLTM template), that too contains the same code and prompts the user to save as again. So my goal is for this code to run only in the initial template and not in the resulting files saved from the template. I hope I've explained that well.
An important point: my template contains a multitude of other code that I will want the saved XLSM files to still contain. I want to eliminate only the code abpove from resulting XLSM files.
Any advice would be most appreciated.
Thanks!
Last edited: