Autosaving file by date as part of the file name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Petertheo
    New Member
    • Aug 2015
    • 1

    Autosaving file by date as part of the file name

    When I use this code the file is only saved at:
    c:\MarketAction s and not in the subfolder \Egypt.

    Where is the problem?

    Code:
    Sub SaveFile()
    ActiveWorkbook.SaveAs ("c:\MarketActions\Egypt\" _
     & Format(Now(), "YYYYMMDDHHMM") & ".xlsm")
    End Sub
    Please advise
    Last edited by Rabbit; Aug 18 '15, 04:11 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    On the basis that there is nothing obvious wrong in what you have posted I suspect that this sub may not be executed as it stands. If the sub folder Egypt was incorrectly named, say, Excel would tell you that the path was invalid. If you have Excel's warning messages turned off then you would not get notification of an error, but nor would the file be saved. Saving one folder up is not behaviour that I recognise.

    I suggest you set a breakpoint in the code which calls the sub, then step through it line by line to check what is going on. Make sure you start with no previous files saved in your folders to avoid potential confusion of your tests.

    -Stewart
    Last edited by Stewart Ross; Aug 19 '15, 05:24 AM.

    Comment

    Working...