Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to check if a folder/directory exist using VBA
Can someone please tell me how can I check if a
directory/folder already exist using VBA within Excel ? I tried the followings and it did not work if Len(Dir("c:\mypath\myfolder")) = 0 then mkdir("c:\mypath\myfolder\newfolder") else msgbox "Folder 'myfolder' already exist." endif Regards |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to check if a folder/directory exist using VBA
You can skip the test
On Error Resume Next mkdir("c:\mypath\myfolder\newfolder") On Error goto 0 this assumes mypath and mypath\myfolder exist. If not, you can use the same principle On Error Resume Next mkdir("C:\mypath") mkdir("C:\mypath\myfolder") mkdir("c:\mypath\myfolder\newfolder") On Error goto 0 -- Regards, Tom Ogilvy "wellie" wrote in message ... Can someone please tell me how can I check if a directory/folder already exist using VBA within Excel ? I tried the followings and it did not work if Len(Dir("c:\mypath\myfolder")) = 0 then mkdir("c:\mypath\myfolder\newfolder") else msgbox "Folder 'myfolder' already exist." endif Regards |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Save file to same directory folder | Excel Discussion (Misc queries) | |||
hyperlink to directory folder while highlighting filename | Links and Linking in Excel | |||
hyperlink to directory folder while highlighting filename | Excel Discussion (Misc queries) | |||
Check for a tab if it is exist | Excel Discussion (Misc queries) | |||
Check if directory empty OR no of files in directory. | Excel Programming |