+ Reply to Thread
Results 1 to 8 of 8

Program tries to create subfolder again when it already exists

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2010, 2013, Office 360
    Posts
    12

    Question Program tries to create subfolder again when it already exists

    Hi,

    I am pretty new to this and am looking for help! I have a macro, in excel 2007, that will create a main folder and then create a sub folder using cell data for both folders. Then it would save the workbook in the sub folder. My problem is that when I go to run the program again, it tries to create the subfolder again, causing an error. What do I need to put in my code to correct this? Any and all help would be appreciated. Thanks in advance.

  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,434

    Re: Program tries to create subfolder again when it already exists

    Use
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    around the line that creates the folder.



    Regards, TMS
    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
    Registered User
    Join Date
    05-29-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2010, 2013, Office 360
    Posts
    12

    Re: Program tries to create subfolder again when it already exists

    Here is the code that I am using. Not sure exactly where to put it.

    Please Login or Register  to view this content.

  4. #4
    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,434

    Re: Program tries to create subfolder again when it already exists

    I guess it's going to go inside this routine: CreateSubfolder

    Regards, TMS

  5. #5
    Registered User
    Join Date
    05-29-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2010, 2013, Office 360
    Posts
    12

    Re: Program tries to create subfolder again when it already exists

    Here is the complete code:

    Please Login or Register  to view this content.
    I get a compile error Expected: expression when I put in On Resume Next. Did you mean On Error Resume Next?
    Last edited by cmce; 07-13-2012 at 09:46 AM.

  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,434

    Re: Program tries to create subfolder again when it already exists

    Sorry, that should have been "On Error Resume Next"

  7. #7
    Registered User
    Join Date
    05-29-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2010, 2013, Office 360
    Posts
    12

    Re: Program tries to create subfolder again when it already exists

    Thanks for the help. I had to put the code in 2 locations to make this work.
    Please Login or Register  to view this content.

  8. #8
    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,434

    Re: Program tries to create subfolder again when it already exists

    You're welcome. Thanks for the rep.

+ 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