ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving with Today's date as part of the string (https://www.excelbanter.com/excel-programming/337174-saving-todays-date-part-string.html)

The Hawk

Saving with Today's date as part of the string
 
Hello all: I'm trying to save a a workbook with the current day's date
(short) automatically as part of the string. I've tried SaveAs and GetSaveAs
with no success. Here is the code:
Private Sub btnSave_Click()
Dim fName As String
MemberDate = xlDateShort
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlNormal
fName = "Member Voting -" & MemberDate

End Sub

Any advice will be sincerely appreciated...


KL

Saving with Today's date as part of the string
 
Hi,

Try this:

Private Sub btnSave_Click()
Dim fName As String
fName="Member Voting -" & Format(Date,"yyyy-mm-dd")
ActiveWorkbook.SaveAs fName
End Sub

Regards,
KL


"The Hawk" wrote in message
...
Hello all: I'm trying to save a a workbook with the current day's date
(short) automatically as part of the string. I've tried SaveAs and
GetSaveAs
with no success. Here is the code:
Private Sub btnSave_Click()
Dim fName As String
MemberDate = xlDateShort
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlNormal
fName = "Member Voting -" & MemberDate

End Sub

Any advice will be sincerely appreciated...




Doug Glancy

Saving with Today's date as part of the string
 
You need to assign the value to fdate before you use it in the SaveAs.

hth,

Doug

"The Hawk" wrote in message
...
Hello all: I'm trying to save a a workbook with the current day's date
(short) automatically as part of the string. I've tried SaveAs and
GetSaveAs
with no success. Here is the code:
Private Sub btnSave_Click()
Dim fName As String
MemberDate = xlDateShort
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlNormal
fName = "Member Voting -" & MemberDate

End Sub

Any advice will be sincerely appreciated...




The Hawk

Saving with Today's date as part of the string
 
It worked Great! Thanks...

"KL" wrote:

Hi,

Try this:

Private Sub btnSave_Click()
Dim fName As String
fName="Member Voting -" & Format(Date,"yyyy-mm-dd")
ActiveWorkbook.SaveAs fName
End Sub

Regards,
KL


"The Hawk" wrote in message
...
Hello all: I'm trying to save a a workbook with the current day's date
(short) automatically as part of the string. I've tried SaveAs and
GetSaveAs
with no success. Here is the code:
Private Sub btnSave_Click()
Dim fName As String
MemberDate = xlDateShort
ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlNormal
fName = "Member Voting -" & MemberDate

End Sub

Any advice will be sincerely appreciated...






All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com