+ Reply to Thread
Results 1 to 6 of 6

Macro to File/Save as "Numbers as of [today's date]" on desktop

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Macro to File/Save as "Numbers as of [today's date]" on desktop

    Hi All,

    I'd like a macro to have the workbook save as

    Numbers as of "today's Date"

    and then close that workbook.

    I already tried the following...

    Sub File_SaveAs()
    '
    ' File_SaveAs Macro
    ' Macro recorded 2/17/2009 by ...
    
        ActiveWorkbook.SaveAs Filename:= _
            "D:\Documents and Settings\Smith\Desktop\Numbers as of.xls" & Format(Date, "mm-dd-yy")
            FileFormat:=xlNormal, Password:="", WriteResPassword:="",
            ReadOnlyRecommended:=False, CreateBackup:=False
    End Sub
    I got a Compile and Syntax error.

    Thanks
    Last edited by duugg; 02-26-2009 at 11:38 AM.

  2. #2
    Registered User
    Join Date
    02-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Macro to File/Save as "Numbers as of [today's date]" on desktop

    try using this for your file name, instead:

    ...
    "D:\Documents and Settings\Smith\Desktop\Numbers as of " & Format(Date, "mm-dd-yy")
     & ".xls" 
    ...

  3. #3
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Macro to File/Save as "Numbers as of [today's date]" on desktop

    I think you also need a comma after the file name and before FileFormat=....

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Macro to File/Save as "Numbers as of [today's date]" on desktop

    I'm lost on this one. I want to do 2 things here

    1. Replace "today's date with the current date, I know that the "DATE" function needs to be used, but I also know that if a comma or () or whatever other character I need is just 1 off, it won't work. Can anyone tell me exactly is wrong here?

    2. How do you record closing a workbook with a macro when there's no way to click on "stop" to stop the macro after it's been closed? What is the exact code for this and where do I put it in the relation to the "File/Save As" macro?

    Thanks much

    Sub File_SaveAs()
    '
    ' File_SaveAs Macro
    ' Macro recorded 2/17/2009 by ...
    '
    
    '
        ActiveWorkbook.SaveAs Filename:= _
            "D:\Documents and Settings\Smith\Desktop\Numbers as of today's date.xls" _
            , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False
    End Sub

  5. #5
    Registered User
    Join Date
    02-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Macro to File/Save as "Numbers as of [today's date]" on desktop

    "Date" by itself gives you today's date (assuming your computer clock is working).

        ActiveWorkbook.SaveAs Filename:= _
    "D:\Documents and Settings\Smith\Desktop\Numbers as of " _
    & Format(Date, "mm-dd-yy") _
    & ".xls"
    this is where you missed the comma in the first version, right before "FileFormat" -- but notice that you don't really need those other options, unless when you opened it, the file was password-protected and read-only and some other format (.txt or .csv, for example).

    If you're using the "Record Macro" button on the toolbar, it's still there after you close a file. When you start recording, specify "New workbook" in the "Store macro in" drop-down box. Then you can close your active workbook and the macro will still be there.
    Last edited by dustycrockett; 02-17-2009 at 07:49 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Macro to File/Save as "Numbers as of [today's date]" on desktop

    Thanks much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1