Hi, JimDandy,
you need to open the template and insert this code into ThisWorkbook:
Dim bln As Boolean
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim strSaveName As String
Dim var As Variant
Dim strNewPart As String
If Len(ThisWorkbook.Path) > 0 Then bln = True
Application.DisplayAlerts = False
If bln = False Then
Cancel = True
bln = True
With ThisWorkbook
If .Path = vbNullString Then
strSaveName = "Underwriting (template).xlsm"
var = Application.GetSaveAsFilename(strSaveName, fileFilter:="Excel Files (*.xlsm), *.xlsm")
If var <> False Then
Do While InStr(1, var, "template") > 0
strNewPart = InputBox(prompt:="Enter the partial new name for saving")
If Len(strNewPart) > 0 Then var = Replace(var, "template", strNewPart)
Loop
End If
Application.EnableEvents = False
.SaveAs var, FileFormat:=52
Application.EnableEvents = True
End If
End With
Else
Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = False
End If
Application.DisplayAlerts = True
End Sub
See if this code is acting the way you expect it to work.
Ciao,
Holger
Bookmarks