Saving with date in filename

B

Ben Allen

I have this code:
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Ben Allen\My
Documents\Eurotours\Eurotours.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Is there a wat to make it say the current month and year after the Eurotours
bit in the name?
Thanks

--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"
 
S

slc

Ben,

I got the solution from Bob Philips in one of the thread. Here is m
code which save the current active sheet into a workbook with curren
sheet name and date.

So for your case, you need to include & Format(Date, "ddmmmyy") afte
your file name and change it mmmyy.


Sub FromSheetoWorkbook()
'
' Create individual workbook from active sheet
'
Dim Fname, strMessage As String
'Save active sheet as a workbook with today's date
Fname = ActiveSheet.Name & "-" & Format(Date, "ddmmmyy")
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=Fname & ".xls"
ActiveWorkbook.Close SaveChanges:=False
' Display saved message
strMessage = Fname & " saved in " & vbCrLf & vbCrLf & CurDir
MsgBox strMessage, vbInformation, "File Saved!"
'
End Su
 
B

Bob Phillips

Hi Ben,

I thought we had already done this one last week?

Anyway

sFilename = "C:\Documents and Settings\Ben Allen\" & _
"My Documents\Eurotours\Eurotours" & _
Format(Date,"yyyy mm") & ".xls",

ActiveWorkbook.SaveAs Filename:= sFil;ename, _
FileFormat:=xlNormal, _
Password:="", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

Brian Baulsom

Something like this :-

MyDate = Format(Date, "dd-mm-yy") ' NB. cannot use slashes
FileName = "C:\Documents and Settings\Ben Allen\My Documents\Eurotours\
" _
& "Eurotours" & " " & MyDate & ".xls"



Regards
BrianB


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Top