Save as before close with an specific name and format

javierorivera

New Member
Joined
Apr 1, 2013
Messages
1
Hello:

This is may first time posting (asking) on the forum.

I created an Excel template (xltm) that automatically saves itself when opened and also automatically adds 1 to cell B1 so it becomes a "pre-numbered" form.

Private Sub Workbook_Open()

Sheets(1).Range("B1").Value = Sheets(1).Range("B1").Value + 1
'
Application.DisplayAlerts = False
Rem more code
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\Javier Rivera Jaume\Desktop\MET1.xltm" _
, FileFormat:=xlOpenXMLTemplateMacroEnabled, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False

Application.DisplayAlerts = True


End Sub


Now: I want to prevent users from saving changes to this template. So, I want the document to automatically save itself (if possible) when closing as a .xls document with the name "Document" and the value in cell "B1". If I can specify the location, better.

Maybe, it can be a button that says 'click here when finish' and that can run a macro...

My VB skills are "limited"...

Thanks you.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,203,515
Messages
6,055,844
Members
444,828
Latest member
StaffordStag

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top