Saving templates to workbooks using a macro

Beckwa

New Member
Joined
Mar 12, 2002
Messages
33
With my booking system I am creating, a template is opened at the beginning of each month and needs to be then saved as a workbook with the name "BkingSystem-March-02" I was wondering if anyone knew of a macro, or how I could create one, which automatically saves the workbook when activated with the above title, but changes due to the month and year which is it saved in. If anyone could help I would greatly appreciate this, Bex X :):)
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Put the following code in the code for your Workbook:

Private Sub Workbook_Open()
ThisWorkbook.SaveAs Filename:="BkingSystem-" & Month(Date) & "-" & Year(Date)
End Sub

Does this work for you or do you want the Month name to appear?
 
Upvote 0
Ok I tried that and it saved as "BkingSystem --1999.xls"

Any ideas on how I can sort this?

BEX
 
Upvote 0
Try this instead:
"BkingSystem-" & Month(Now) & "-" & Year(Now)

What version of excel are you running?
 
Upvote 0
Try,

Private Sub Workbook_Open()
Dim MyDate
Dim MyMonth
MyDate = Date
MyMonth = Month(MyDate)
ThisWorkbook.SaveAs Filename:="BkingSystem-" & MonthName(MyMonth) & "-" & Year(Date)
End Sub

Hope this helps. JSW

P.S. The code go's in the "ThisWorkBook" module!

Note: I tested the code and it saved the file as: BkingSystem-March-2002.xls in the active directory?
This message was edited by Joe Was on 2002-03-20 14:53
This message was edited by Joe Was on 2002-03-20 14:57
 
Upvote 0
Howdy Bex. You may want to verify your computer system's date and time. Double click on the clock on the bottom right of your screen, in the windows task bar and make sure it's current (assuming your using Windows).

Food for thought :)

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-03-20 14:50
 
Upvote 0
I've tried it on both Windows 98 and Windows XP and the same problem occurs, any ideas,

BEX
xx
 
Upvote 0
What version of excel are you running, and like Nate is implying, your system time and date are completely wrong.
 
Upvote 0
I've tried it on both Windows 98 and Windows XP and the same problem occurs, any ideas,

BEX
xx
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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