+ Reply to Thread
Results 1 to 7 of 7

& Date &

  1. #1
    Registered User
    Join Date
    11-14-2004
    Location
    Georgia
    Posts
    57

    Arrow & Date &

    i'm trying to create a macro that will save a document as "weekly schedule" and the current date. this is what i have so far

    Option Explicit

    Sub SaveIt()

    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Stephen\My Documents\thisbook" & Date & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    End Sub

    but that doesn't work becasue of the bolded code.

    i can get it to insert the contents of a cell into the filename, but not the date. do i have to just put the date in a cell?

    thanks,
    stephen
    Brought to you by Pringles and his infinite genius. ~''~

    "Ctrl+Z is a beautiful thing."
    - Me.

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    try this

    Sub SaveIt()

    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Stephen\My Documents\thisbook" & format(Date,"DD-MM-YY") & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    End Sub

  3. #3
    Registered User
    Join Date
    11-14-2004
    Location
    Georgia
    Posts
    57
    got it.

    thanks.

  4. #4
    Registered User
    Join Date
    11-14-2004
    Location
    Georgia
    Posts
    57

    Exclamation

    well ok, i have one more problem:

    this is what i have now:

    Sub DateSave()

    Dim dt As Date
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Page1")
    dt = ws.Range("A1")
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Stephen\My Documents\Test - " & Format(dt, "MM-DD-YYYY") & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False

    Set ws = Nothing

    End Sub


    but for some reason it's giving me the date as 1-9-1899.

    i would like to have:

    Sub DateSave()
    '
    ' DateSave Macro
    ' Saves the Document with the current date
    '
    Dim dt As String
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Page1")
    txt = ws.Range("A1")
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Stephen\My Documents\Test - " & dt & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False

    Set ws = Nothing

    End Sub

    but this is just not working. any help?

    thanks,
    stephen
    Last edited by medicenpringles; 01-09-2005 at 03:20 PM.

  5. #5
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    what is the value in cell a1 of sheet page1

  6. #6
    Registered User
    Join Date
    11-14-2004
    Location
    Georgia
    Posts
    57
    1/9/2005

    and it's formated as dddd, mmmm dd, yyyy so that is returns "Sunday, January 09, 2005"

  7. #7
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    minor change



    Sub DateSave()
    '
    ' DateSave Macro
    ' Saves the Document with the current date
    '
    Dim dt As String
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Page1")
    dt = ws.Range("A1")
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Stephen\My Documents\Test - " & dt & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False

    Set ws = Nothing

    End Sub

+ 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