Consulting

Results 1 to 5 of 5

Thread: save workbook titled with current date

  1. #1

    save workbook titled with current date

    Hello,

    simple question, I would like to save the "TESTING.xls" workbook as "TESTING 5/20/2006.xls" or "TESTING 5thMay2006". I tried using "I:\TESTING" & Date ".xls" and "I:\TESTING.xls" & Date, but obviously excel didnt like it and refuse to do so. Can someone please advise.
    Thank you

    Yours,
    Ed


    [VBA]

    sub newWorkbook()

    Workbooks.Add
    ActiveWorkbook.SaveAs Filename:= _
    "I:\TESTING.xls", FileFormat:=xlNormal, _
    Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
    CreateBackup:=False

    end sub
    [/VBA]

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Try this.
    [vba]
    Sub newWorkbook()

    Workbooks.Add
    ActiveWorkbook.SaveAs Filename:="I:\TESTING " & Format(Date, "ddmmmyyyy") & _
    ".xls", FileFormat:=xlNormal

    End Sub

    [/vba]

  3. #3
    Thanks Norie, That was what i needed however, any suggestion if it has to display the date of yesterday?
    Thank you.

    yours,
    Ed

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    to save it to the hard drive.....
    [VBA]
    Sub saveas()
    Dim newFile As String, fName As String
    ' Don't use "/" in date, invalid syntax
    fName = "TESTING"
    newFile = fName & " " & Format$(Date, "mm-dd-yyyy")
    ' Change directory to suit
    ChDir _
    "F:\Temp"
    ActiveWorkbook.saveas Filename:=newFile
    End Sub
    [/VBA]

    to save as yesterdays date:
    [VBA]
    Sub saveas()
    Dim newFile As String, fName As String
    ' Don't use "/" in date, invalid syntax
    fName = "TESTING"
    newFile = fName & " " & Format$(Date - 1, "mm-dd-yyyy")
    ' Change directory to suit
    ChDir _
    "F:\Temp"
    ActiveWorkbook.saveas Filename:=newFile
    End Sub
    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Thanks for the prompt replies, they work perfectly
    Thank you

    yours,
    Ed

Posting Permissions

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