ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Control Name when New workbook opened from a template (https://www.excelbanter.com/excel-discussion-misc-queries/249365-control-name-when-new-workbook-opened-template.html)

SC in Texas

Control Name when New workbook opened from a template
 
How can I control the name of a new workbook opened from template?
Such as using MyWorkbook.xlt to open MyWorkBookToday.xls instead of
MyWorkbook1.xls.

Thanks,
Steve
--
SC from Lubbock, Texas

Dave Peterson

Control Name when New workbook opened from a template
 
The name of the file (including the extension) is set when you (or the user)
saves the file.

I don't think you can control how excel names workbooks that are created based
on template files.

Well, you could provide a macro that creates the file and then saves the file
with the name (and location) you want.

SC in Texas wrote:

How can I control the name of a new workbook opened from template?
Such as using MyWorkbook.xlt to open MyWorkBookToday.xls instead of
MyWorkbook1.xls.

Thanks,
Steve
--
SC from Lubbock, Texas


--

Dave Peterson

Gord Dibben

Control Name when New workbook opened from a template
 
It can be done but what if you open the Template more than once per day?

This code placed in Thisworkbook module of MyBook.xlt will immediately save
the copy as mybookmm-dd-yyyy.xls but if a copy with that name already exists
what do you want to do?

Private Sub Workbook_Open()

If ActiveWorkbook.Path < "" Then Exit Sub
'allows you to open a saved copy without renaming

'names and saves newly opened copy
ActiveWorkbook.SaveAs Filename:= _
"C:\Program Files\Microsoft Office\Exceldata\mybook" & _
Format(Date, "mm-dd-yyyy") & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False _
, CreateBackup:=False

End Sub


Gord Dibben MS Excel MVP

On Wed, 25 Nov 2009 07:54:16 -0800, SC in Texas
wrote:

How can I control the name of a new workbook opened from template?
Such as using MyWorkbook.xlt to open MyWorkBookToday.xls instead of
MyWorkbook1.xls.

Thanks,
Steve




All times are GMT +1. The time now is 03:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com