Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Unanswered: Macro Save As - Wrong Location

    Hi

    I'm using this macro to save a file with a title and today's date to a specific location.

    Dim newFile As String, fName As String
    fName = Range("B1").Value
    newFile = fName & " " & Format$(Date, "mm-dd-yyyy")
    ChDir _
    "X:\Common\Service Centre\End of day reports\Current Report"
    ActiveWorkbook.SaveAs Filename:=newFile

    However on some occasions this macro is saving to My Documents rather than the file path shown above.

    Can anyone help? Thanks

  2. #2
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    Hi,

    Try including the path in the FileName argument.

    Code:
    Dim newFile As String, fName As String
     
    fName = Range("B1").Value
    newFile = fName & " " & Format$(Date, "mm-dd-yyyy")
     
    ActiveWorkbook.SaveAs Filename:= _
        "X:\Common\Service Centre\End of day reports\Current Report" & newFile

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Thanks, but the result is as follows:
    - saving at X:\Common\Service Centre\End of day reports
    - "Current Report" is now part of the file name

  4. #4
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    My mistake, you need a \ after Current Report like this:
    Code:
    ActiveWorkbook.SaveAs Filename:= _
        "X:\Common\Service Centre\End of day reports\Current Report\" & newFile

Posting Permissions

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