+ Reply to Thread
Results 1 to 8 of 8

Trying to use MkDir to create new folder with multiple subfolders

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Trying to use MkDir to create new folder with multiple subfolders

    Hi everyone,

    The following is a portion of a larger macro I have which creates new folders in a directory to save files:

    Please Login or Register  to view this content.
    This code works great when SDir is in the following format: ABC\ or YYY\
    However, if SDir becomes ABC\YYY\ then I get a path not found message (error 76). SDir is a string value from a single cell. So it seems MkDir can't make a directory with a subfolder(s).

    Does anyone know of any way to adjust the code to allow subfolders?

    Thanks!!

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Trying to use MkDir to create new folder with multiple subfolders

    Try using CHDIR after creating the directory. Then use MKDIR to create the subdirectories just using the name: MKDIR "SUBDIR1", etc.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Trying to use MkDir to create new folder with multiple subfolders

    Hi proton,

    Thanks for your reply. I'm not certain how I would apply your suggestion. Like this:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Trying to use MkDir to create new folder with multiple subfolders

    Does this help?
    Please Login or Register  to view this content.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Trying to use MkDir to create new folder with multiple subfolders

    @ protonLeah

    Subfolders weren't created with your code. (on my laptop)
    This one does.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Trying to use MkDir to create new folder with multiple subfolders

    I tested on my machine before posting.

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Trying to use MkDir to create new folder with multiple subfolders

    Please Login or Register  to view this content.

  8. #8
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Trying to use MkDir to create new folder with multiple subfolders

    I have faced similar issues before, so I made this:
    Please Login or Register  to view this content.
    To use in your full code, simply do this:
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

+ 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. Create a folder to save a file and two subfolders in a defined path
    By Biplab1985 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-01-2015, 11:43 AM
  2. [SOLVED] Macro to create hyperlink list of every file in a folder, subfolders
    By itmanusa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2013, 12:43 PM
  3. Macro to create hyperlink list of every file in a folder, subfolders, and SHORTCUTS
    By Billdick7788 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2013, 11:11 AM
  4. Adapt macro to create list of all PDF files in folder, including subfolders.
    By Glensafro in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2013, 06:33 AM
  5. Insert Multiple Hyperlinks from Folder and Subfolders
    By leonardapple in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 02-27-2013, 11:10 AM
  6. creating multiple subfolders inside a folder
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2012, 01:27 AM
  7. Create Both Folder and Subfolders using Coloum A and B
    By IainB in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-25-2009, 09:03 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