+ Reply to Thread
Results 1 to 2 of 2

Check if folder exists, Create if Not

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Check if folder exists, Create if Not

    Hi All,

    I need to have a vba code to check if the folder named work_<datestamp> exists in C:/Temp and create one if it doesnt exist.

    If Exist, delete all the contents of it.

    Can anyone help me with this?

    Thank you.

  2. #2
    Forum Contributor
    Join Date
    02-23-2013
    Location
    Bangalore
    MS-Off Ver
    2010
    Posts
    130

    Re: Check if folder exists, Create if Not

    No problem.. i did it myself.. Thanks..

     sWorkDir = sDefault_Dir & "\" & "work_" & currentDate
        If Dir(sWorkDir, vbDirectory) = "" Then
            MkDir sWorkDir
        Else
            'Delete files
            fso.deletefile sWorkDir & "\*.*", True
            'Delete subfolders
            fso.deletefolder sWorkDir & "\*.*", True
        End If

+ 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. Check if Folder exists
    By akq125 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-02-2012, 10:35 PM
  2. Check if a mailbox folder exists
    By fcomino in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-24-2010, 09:08 AM
  3. Check if folder exists, if not create it
    By mattmac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2009, 10:17 AM
  4. Check if folder exists, if yes just copy sheet in to folder?
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2006, 10:44 AM
  5. how to check if folder exists
    By funkymonkUK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-14-2005, 07: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