+ Reply to Thread
Results 1 to 4 of 4

Saving in a folder (and subfolders) based on user input

  1. #1
    Registered User
    Join Date
    04-05-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Saving in a folder (and subfolders) based on user input

    I am using a Form to set values of variables. I then want to use these values to direct excel where to save the file.
    Please Login or Register  to view this content.
    I keep getting an error when the file tries to save, saying that it cannot find the file. Could someone please help, thanks in advance.

    Stayci
    Last edited by Wanting_To_Learn; 04-06-2011 at 07:07 AM. Reason: It is solved now

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Saving in a folder (and subfolders) based on user input

    Stacyi,

    If a workbook tries to save in a folder location that doesn't exist, you'll get an error. I'd recommend adding to your code a check to see if the folder exists already and if it does, just save the workbook, otherwise create the folder and then save the workbook:

    Please Login or Register  to view this content.


    Hope this helps,
    ~tigeravatar
    Last edited by tigeravatar; 04-05-2011 at 03:10 PM. Reason: Commented code

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Saving in a folder (and subfolders) based on user input

    Stacyi,

    It occurred to me that the macro might have to make several folders to get to the desired folder that it is being saved to. Unfortunately, the macro will fail if it has to create more than one folder. So I modified the code to provide a loop that will create each subfolder so that the workbook can be saved in the desired location:

    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar
    Last edited by tigeravatar; 04-05-2011 at 03:53 PM. Reason: Commented code

  4. #4
    Registered User
    Join Date
    04-05-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Saving in a folder (and subfolders) based on user input

    Thank you Tiger

    The second code worked perfectly. I do find it odd because the folders were there, but, this seems to do the job. Thanks again!

    Stayci

+ 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