[Log In ] [New Posts] []
Go Back   GotApex? Forums Forums > General Topics > Software, OS, and the Internet
User Name
Password

Reply
 
Thread Tools Search this Thread Display Modes
Old 12-09-2005, 04:47 PM   #1
fiestaball
Ensign
 
fiestaball's Avatar
 
Join Date: Nov 2005
Posts: 20
Command Button Programming In Excel

Anyone know how to program a command button in Excel? Here is what I am trying to do. I need a command button that when clicked will save my current file and append the date to the end. e.g. 'Backup12092005'. I have tried to record a macro and then look at the code and then tried to append '=TODAY()'
but that results in the file being saved as 'Backup=TODAY()' which is not what I desire to happen.
fiestaball is offline   Reply With Quote
Old 12-09-2005, 08:56 PM   #2
dbax791
Rear Admiral Lower Half
 
dbax791's Avatar
 
Join Date: Feb 2000
Location: Arizona
Posts: 2,177
Send a message via AIM to dbax791
It's because Today() is an excel function and not an Excel VBA function.

Getting dates to save in that format is a little tricky in VBA but it can be done:

Dim Filename As String

Filename = "C:\temp\test" & CStr(DatePart("m", Date)) & CStr(DatePart("d", Date)) & CStr(DatePart("yyyy", Date)) & ".xls"


ActiveWorkbook.SaveAs Filename:= _
Filename, FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
End Sub
dbax791 is offline   Reply With Quote
Old 12-09-2005, 09:31 PM   #3
eSDee
Old Skooler Numba 1
 
eSDee's Avatar
 
Join Date: Nov 2000
Location: Diego
Posts: 10,063
Send a message via AIM to eSDee
you're the man dbax
__________________
~~~~~~~~~~~~
3 days ~ Willie Nelson

3 days I dread to see arrive
3 days I hate to be alive
3 days filled with tears and sorrow
yesterday today and tomorrow
eSDee is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 05:26 PM.