PC Review


Reply
Thread Tools Rate Thread

Control Name when New workbook opened from a template

 
 
SC in Texas
Guest
Posts: n/a
 
      25th Nov 2009
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
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      25th Nov 2009
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
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      25th Nov 2009
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
<(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting new workbook name from opened template Ronio Microsoft Excel Programming 1 10th Jan 2008 04:35 PM
Exceeding 65K of defined names within workbook causes workbook to go into repair mode when it is opened Ronald Dodge Microsoft Excel Programming 13 18th May 2007 02:24 PM
How to check workbook is already opened before passing the workbook obj to a subroutine in Word Bon Microsoft Excel Programming 2 19th Jan 2006 09:54 AM
Opening a workbook if not opened, going to it if already opened neotokyo Microsoft Excel Programming 1 24th Sep 2004 07:17 PM
Sheets select method fails when workbook is opened by another workbook Mike Microsoft Excel Programming 2 8th Jun 2004 04:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 PM.