View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Workbook_BeforeSave question

Maybe this

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If ThisWorkbook.Name < "template.xls" Then Exit Sub
If SaveAsUI Then
'do nothing
Else
Cancel = True
End If
End Sub

Sub Savethetemplate()
Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Barb Reinhardt" wrote in message
...
If I check the ActiveWorkbook.name against the predefined name of the
template and it matches, how do I force a SaveAs?

"Ron de Bruin" wrote:

Hi Barb

You can use this

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
'do nothing
Else
Cancel = True
End If
End Sub

But if you use save as to another name the code is also working
Maybe add a check for the template name


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Barb Reinhardt" wrote in message
...
Does it make sense to force a SAVEAS during the workbook_beforesave event?
We have a "template" (not in the Excel terminology) that we don't want
overwritten. Is there a recommended way to ensure that doesn't happen with
the Workbook_beforesave or another method?

Thanks,