+ Reply to Thread
Results 1 to 4 of 4

Trouble saving a worsheet to a file using macros.

  1. #1
    phoenixx153
    Guest

    Trouble saving a worsheet to a file using macros.

    I have set up a macro using the following code to save my worksheet as a
    seperate file using the days date as the filename eg 21012005.xls

    Sheets("*****").Copy
    strAppend = Format(Date, "DDMMYYYY")
    strPath = "*****"
    fSaveName = strPath & strAppend & ".xls"
    ActiveWorkbook.SaveAs fSaveName
    ActiveWorkbook.Close

    I would like to put in a code that says if that file (21012005.xls) all
    ready exists, add an "a" after the date,eg "21012005a.xls".

    Can this be done? I'm only new to using macros and any help would be greatly
    appreciated.

  2. #2
    Tom Ogilvy
    Guest

    Re: Trouble saving a worsheet to a file using macros.

    Sheets("*****").Copy
    strAppend = Format(Date, "DDMMYYYY")
    strPath = "*****"
    fSaveName = strPath & strAppend & ".xls"
    if dir(fSaveName) <> "" then
    fSaveName = strPath & strAppend & "a.xls"
    End If
    ActiveWorkbook.SaveAs fSaveName
    ActiveWorkbook.Close

    --
    Regards,
    Tom Ogilvy


    "phoenixx153" <[email protected]> wrote in message
    news:[email protected]...
    > I have set up a macro using the following code to save my worksheet as a
    > seperate file using the days date as the filename eg 21012005.xls
    >
    > Sheets("*****").Copy
    > strAppend = Format(Date, "DDMMYYYY")
    > strPath = "*****"
    > fSaveName = strPath & strAppend & ".xls"
    > ActiveWorkbook.SaveAs fSaveName
    > ActiveWorkbook.Close
    >
    > I would like to put in a code that says if that file (21012005.xls) all
    > ready exists, add an "a" after the date,eg "21012005a.xls".
    >
    > Can this be done? I'm only new to using macros and any help would be

    greatly
    > appreciated.




  3. #3
    phoenixx153
    Guest

    Re: Trouble saving a worsheet to a file using macros.

    Thank you very much Tom.
    I appreciate it immensly

    "Tom Ogilvy" wrote:

    > Sheets("*****").Copy
    > strAppend = Format(Date, "DDMMYYYY")
    > strPath = "*****"
    > fSaveName = strPath & strAppend & ".xls"
    > if dir(fSaveName) <> "" then
    > fSaveName = strPath & strAppend & "a.xls"
    > End If
    > ActiveWorkbook.SaveAs fSaveName
    > ActiveWorkbook.Close
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "phoenixx153" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have set up a macro using the following code to save my worksheet as a
    > > seperate file using the days date as the filename eg 21012005.xls
    > >
    > > Sheets("*****").Copy
    > > strAppend = Format(Date, "DDMMYYYY")
    > > strPath = "*****"
    > > fSaveName = strPath & strAppend & ".xls"
    > > ActiveWorkbook.SaveAs fSaveName
    > > ActiveWorkbook.Close
    > >
    > > I would like to put in a code that says if that file (21012005.xls) all
    > > ready exists, add an "a" after the date,eg "21012005a.xls".
    > >
    > > Can this be done? I'm only new to using macros and any help would be

    > greatly
    > > appreciated.

    >
    >
    >


  4. #4
    J_J
    Guest

    Re: Trouble saving a worsheet to a file using macros.

    Tom, can I add an additional Q. here?
    Can your modify your code so that the new created "DDMMYYYY.xls" formatted
    file will not contain the original file macro codes and possible control
    button figures on the copied sheet?
    Regards
    J_J

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Sheets("*****").Copy
    > strAppend = Format(Date, "DDMMYYYY")
    > strPath = "*****"
    > fSaveName = strPath & strAppend & ".xls"
    > if dir(fSaveName) <> "" then
    > fSaveName = strPath & strAppend & "a.xls"
    > End If
    > ActiveWorkbook.SaveAs fSaveName
    > ActiveWorkbook.Close
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "phoenixx153" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have set up a macro using the following code to save my worksheet as a
    > > seperate file using the days date as the filename eg 21012005.xls
    > >
    > > Sheets("*****").Copy
    > > strAppend = Format(Date, "DDMMYYYY")
    > > strPath = "*****"
    > > fSaveName = strPath & strAppend & ".xls"
    > > ActiveWorkbook.SaveAs fSaveName
    > > ActiveWorkbook.Close
    > >
    > > I would like to put in a code that says if that file (21012005.xls) all
    > > ready exists, add an "a" after the date,eg "21012005a.xls".
    > >
    > > Can this be done? I'm only new to using macros and any help would be

    > greatly
    > > appreciated.

    >
    >




+ 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