Consulting

Results 1 to 3 of 3

Thread: Solved: Create folders if don't exist

  1. #1

    Solved: Create folders if don't exist

    Hi,

    I'm using a macro to fire off a process where a master file is saved under a different name and in a different folder. Everything works as it should unless the target path contains folders that don't exists.

    Is it possible to have the macro create any folders in the path that don't already exist?

    This is needed for auditing purposes as the folders are based upon the month and year of parameter values passed by the user, I could create them in theory in advance but it would quickly become messy as I would have to create many many folders. It would be nice if Excel could recognise that folder(s) in the path do not exist and create them as required but I don't know if this feature exists within VBA.

    Thanks in advance,

    Paul
    Keep the rubber side down and the shiny side up

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    On ERror Resume Next

    MkDir "C:\Level1"
    MkDir "C:\Level1\Level2"
    MkDir "C:\Level1\Level2\Level3"
    MkDir "C:\Level1\Level2\Level3\myDir"
    On Error Goto 0
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Great stuff, thank you so very much!
    Keep the rubber side down and the shiny side up

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •