Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SAVE AS .... Different Folder (xp/1)

    I'm having a bit of difficulty getting a file SAVED AS in a new parallel folder:

    MyFile is in FOLDER A
    I want to save it as MyFile in FOLDER B

    If FOLDER B is INSIDE FOLDER A the following works:


    ThisWorkbook.SaveAs Filename:= _
    ThisWorkbook.Path & "FOLDER BMyFile.xls"

    However, I need FOLDER B to be parallel to FOLDER A and I need the path to be RELATIVE to THIS WORKBOOK. Hence I need the parent location. When I inserted ".PARENT" in the code after "ThisWorkbook" the path took me back to "OFFICE". I also tried: "."

    Paul

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: SAVE AS .... Different Folder (xp/1)

    Try this:

    ThisWorkbook.SaveAs Filename:= _
    application.WorksheetFunction.Substitute ( _
    ThisWorkbook.fullname, "FOLDER A", "FOLDER B")

    or if the filename is different:

    ThisWorkbook.SaveAs Filename:= _
    application.WorksheetFunction.Substitute ( _
    ThisWorkbook.path, "FOLDER A", "FOLDER B") & "MyFile.xls"

    The "substitute" function will replace the one folder name for the other.

    Steve

  3. #3
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SAVE AS .... Different Folder (xp/1)

    Thanks Steve

    That did it. I haven't used SUBSTITUTE before......always something new.

  4. #4
    Star Lounger
    Join Date
    Mar 2001
    Location
    Ontario, Canada
    Posts
    57
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: SAVE AS .... Different Folder (xp/1)

    If you want the path to be relative to the current folder, then you shouldn't put in ThisWorkbook.path.

    Wouldn't a simple
    ThisWorkbook.SaveAs Filename:= "..FOLDER BMyFile.xls" do the trick?

Posting Permissions

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