Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB to Save file as Month

Status
Not open for further replies.

DanAuber

IS-IT--Management
Apr 28, 2000
255
FR
I want to modify the following code so that it Save the file as "Invoices " and then the current month:

ActiveWorkbook.SaveAs Filename:="C:\Auto Invoices\Invoices Month.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Thus if we are in October, running the code would save the file as "Invoices October" or "Invoices Oct" if it is easier.

Can anyone supply me with this code ?

Thanks in advance

 
Use this:

ActiveWorkbook.SaveAs Filename:="C:\Auto Invoices\Invoices " & format(now,"mmmm") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
 
ActiveWorkbook.SaveAs Filename:="C:\Auto Invoices\Invoices " & MonthName(Month(Date)) & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
 
I would suggest adding the year besides the month in the name unless this will only be used for a short time or you plan on over writing.
djj
 
I second djj. A common format used is
[tab]format(now,"yyyymm")
so they will sort easily.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top