Quote:
|
Originally Posted by bhavesh78
I have a standard excel template which is a read-only file (with company logo etc.). All excel worksheets are based on this basic template.
~BS
|
Pretty simple really. Just set the macro to run of your button to this code. One thing to note: You should save the actual template as a template File with the '.xlt' extension. You must save it through the Excel Save dialog to do this (just changing the name won't make it a template) Once in a template you do not need to explicitly open it in read only. Just use the ' Workbooks.Add Template' method. It's better to do this way because if the user cancels the saveas dialog without saving when they go to save the file it will promt for a name to save to, just like saving a new workbook will do.
Code:
Sub OpenTemplateSave()
Dim fPath As String
Dim fFile As String
fPath = Application.TemplatesPath
fFile = "CompanyInvoice0.xlt"
ChDir "C:\Documents and Settings"
Workbooks.Add Template:=fPath & fFile
Application.GetSaveAsFilename , , , "Save a New Company Invoice"
End Sub