+ Reply to Thread
Results 1 to 7 of 7

Saving an Excel file in a designated folder

  1. #1
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Saving an Excel file in a designated folder

    Hi All,

    I need help with the correct code to enable me to save an Excel file in a specific/designated folder on my computer.

    I have an invoice program which, after being generated, prints and saves a copy as PDF in the same folder where the invoice program resides. The printing and saving currently works OK, and the code that does the saving is as follows:

    Please Login or Register  to view this content.
    The above code saves the PDF copy in the same folder as the Invoice program. However, I would like the PDF copy to be saved in a designated folder named 'Copy Invoices' on my desktop and not in the same folder as the main Invoice program, which, currently is the situation. Here is the Path to the designated folder in which I want the PDF copy to be stored:

    "ChDir C:\Documents and Settings\Me\Desktop\Copy Invoices"

    I therefore need help, please, to incorporate this path into the above code so that the PDF copy will be saved in the 'Copy Invoices' folder on my desktop.

    Thanks for your help.

    Buddy
    Last edited by Buddy8; 05-16-2016 at 08:46 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,462

    Re: Saving an Excel file in a designated folder

    Change this:

    Please Login or Register  to view this content.

    To this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,209

    Re: Saving an Excel file in a designated folder

    Try

    Path = "C:\Documents and Settings\Me\Desktop\Copy Invoices"

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Path & "\" & sNewWorkbookName & " - " & [H5], Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False

  4. #4
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Saving an Excel file in a designated folder

    Thanks TMS for your help. Your code works perfectly OK. Very happy.

    Buddy

  5. #5
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Saving an Excel file in a designated folder

    Thanks John for your help. Your version of the code works perfectly OK too, just like TMS' version. I'm spoilt for choice. Both of you have been very helpful. I'm grateful.

    Buddy

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,462

    Re: Saving an Excel file in a designated folder

    You're welcome. Thanks for the rep.


    If you only use the location once, it doesn't make much difference. If you use it several times, it would make sense to use John's approach. The big advantage of defining and using a variable is that it makes it easier to locate and change, should you want to. I was just addressing the immediate problem with the information provided.

  7. #7
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Saving an Excel file in a designated folder

    Thanks TMS for your suggestion. Yes, I agree with you that where the location is likely to change any number of times, then it would be best to use John's approach. Both of you have been very kind with your very good approaches.

    Grateful to both of you.

    Buddy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Saving file to a specific folder
    By richkim2000 in forum Excel General
    Replies: 3
    Last Post: 04-17-2016, 11:32 AM
  2. [SOLVED] Saving multiple file versions in the same folder if file already exists
    By lsargent in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2015, 10:49 AM
  3. Replies: 0
    Last Post: 04-21-2014, 04:03 PM
  4. Saving File using input from excel sheet (folder and filenames)
    By officedepot in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 01:26 PM
  5. Rename File Names & Repost to Designated Folder
    By Surfmaster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2012, 01:45 PM
  6. [SOLVED] Saving a file to new folder dependant on the first letter of the file name.
    By G_La_Mood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 10:58 AM
  7. Replies: 4
    Last Post: 12-30-2011, 11:24 AM

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