Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Save Special Filename Multiple Times

Hi!

I have a spreadsheet (form) template that our staff types info into.
One field is the "Date of Issue" and another the "customer id" (among many
other fields).

This forum taught me how to have excel save my generic template with a
unique name "customer id"+today's date ex. 123_20060603.

This has worked really well, because, sometimes the same customer will have
another form. So, 123_20061231 works great.

Now, I would like to know if there is a way to prompt or automate an option:
Is this an existing form that you are appending to?
Yes, means I save the file with the existing name 123_20060603
No, means I save with a new file name 123_todays date.

I'm not certain I could be this smart, but, there is a way to tell. When you
first open this worksheet, if it was opened as a template ".xlt", then run
the macro and use the new data in J2. If opened as ".xls" overwrite the
existing file (maybe with an "Are you sure?" prompt) and do not execute the
rest of the macro.

I still very new at the macro, vba thing, so if you have any truly great
ideas, please be very specific.

Here is the existing code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
ThisWorkbook.SaveAs Filename:=Worksheets("Sheet1").Range("J2").Value, _
FileFormat:=xlWorkbookNormal
Application.EnableEvents = True
End Sub

Thank you SOoooo much!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Save Special Filename Multiple Times

Just look at the existing file name:

activeworkbook.name

Put an if statement in your beforesave function. If its xlt, then make
the new file. If its .xls, then just do a save. Hope this helps.

If Right(ActiveWorkbook.Name, 3)="xls" Then
**do one thing
ElseIf Right(ActiveWorkbook.Name, 3) = "xlt" Then
**Do something else
End If


DTTODGG wrote:
Hi!

I have a spreadsheet (form) template that our staff types info into.
One field is the "Date of Issue" and another the "customer id" (among many
other fields).

This forum taught me how to have excel save my generic template with a
unique name "customer id"+today's date ex. 123_20060603.

This has worked really well, because, sometimes the same customer will have
another form. So, 123_20061231 works great.

Now, I would like to know if there is a way to prompt or automate an option:
Is this an existing form that you are appending to?
Yes, means I save the file with the existing name 123_20060603
No, means I save with a new file name 123_todays date.

I'm not certain I could be this smart, but, there is a way to tell. When you
first open this worksheet, if it was opened as a template ".xlt", then run
the macro and use the new data in J2. If opened as ".xls" overwrite the
existing file (maybe with an "Are you sure?" prompt) and do not execute the
rest of the macro.

I still very new at the macro, vba thing, so if you have any truly great
ideas, please be very specific.

Here is the existing code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
Cancel = True
ThisWorkbook.SaveAs Filename:=Worksheets("Sheet1").Range("J2").Value, _
FileFormat:=xlWorkbookNormal
Application.EnableEvents = True
End Sub

Thank you SOoooo much!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
Need To save a spreadsheet multiple times through a macro mibsaweiss Excel Programming 2 April 19th 06 03:09 PM
Long Save Times with File-Save BrianDavid Excel Discussion (Misc queries) 3 December 20th 05 03:57 PM
Save Filename Peter Excel Programming 3 February 4th 05 01:15 PM
save as filename Geo Siggy[_14_] Excel Programming 3 April 6th 04 01:26 PM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"