+ Reply to Thread
Results 1 to 8 of 8

Mkdir command button to add subfolder/subfolder

  1. #1
    Registered User
    Join Date
    07-14-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    5

    Mkdir command button to add subfolder/subfolder

    I am trying to create this command button to Mkdir. I want to take it further by creating a folder then subfolder using cell "A1" and "B1" and then use "C1" to name the file once the other folders have been created. I don't know if this is making sense. Thanks for your help.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Mkdir command button to add subfolder/subfolder

    Maybe:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-14-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Mkdir command button to add subfolder/subfolder

    hey kyle, i can't get the thing to run. I'm new at excel, so bear with me. How do i get it to perform it's action. I went to "macros", selected it and hit run but it doesn't do anything.

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

    Re: Mkdir command button to add subfolder/subfolder

    Just make the folder(s) before doing the save and then check if it exists and exit your routine if it does not.

    To test Kyles function, run his Test sub.

    If you don't mind a slight flash of the DOS shell, these methods work fine. Uncomment the one you want to try.
    Please Login or Register  to view this content.

    Another good fso solution to iteratively create subfolders as shown by Chip Pearson at: http://www.cpearson.com/excel/MakeDirMulti.aspx

    Just because code is large, does not mean it is bad. Lots of error routines makes for robust routines. e.g. Chip's code checks to see if the drive exists.
    Last edited by Kenneth Hobson; 07-17-2013 at 05:21 PM.

  5. #5
    Registered User
    Join Date
    07-14-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Mkdir command button to add subfolder/subfolder

    Ken,

    When i try to run Kyle's macro it doesn't work. I go to "macro's, select macro, and hit run". I get a 400 error.

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

    Re: Mkdir command button to add subfolder/subfolder

    You put his code into a Module and ran the sub Test? After doing that, try this test sub in that module. Make note of the MsgBox, does that string make sense? Try saving the XLSM in a macro recording to make sure that syntax is proper. There can be a problem between file types. The recorder is your friend.
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 07-17-2013 at 03:43 PM.

  7. #7
    Registered User
    Join Date
    07-14-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Mkdir command button to add subfolder/subfolder

    it highlights "MkDir2 s" and i get error "compile error: sub or function not defined"

    I'm tellin ya, i'm about as dumb with VBA as you can get.. WAY OFF.

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

    Re: Mkdir command button to add subfolder/subfolder

    Try posting a workbook so that we can see what is going on. IN particular, the cell values and your code of course in the XLSM file.

    Most people use the D: drive as a cdrom drive so that would fail for them. I used a virtual drive, X, for testing my code.

    Don't be afraid to import Chip's routines. They are not difficult to use.

    I used to use methods like Kyles but I get lazy and fall back to my DOS days. Of course that method, has no error checking at all such as a drive check or legal folder name check.
    Last edited by Kenneth Hobson; 07-17-2013 at 05:27 PM.

  9. #9
    Registered User
    Join Date
    07-14-2013
    Location
    N/A
    MS-Off Ver
    Excel 2003
    Posts
    5

    Cool Re: Mkdir command button to add subfolder/subfolder

    I am an idiot, I combined both of the codes that Kyle and Ken had sent and it works perfectly. thank you very much for the patience and help.

+ 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. Moving an e-mail from a subfolder in Mailbox to the equivalent subfolder in an archive PST
    By johncassell in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2012, 11:31 AM
  2. Move a Subfolder with Contents
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2010, 04:51 PM
  3. Subfolder Search
    By kreshnr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-25-2009, 09:49 AM
  4. Selecting a Folder or Subfolder
    By Rabi in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-08-2006, 06:39 PM
  5. Create a subfolder
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2006, 07:34 PM

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