![]() |
Testing for a directory
Hi,
I need to test if a directory exists and if not create it. All I can think of is to use on error and try and open it, they create a new directory if it fails. Any sugestions of a more elegant way |
Testing for a directory
This works for me.....
Dim sFolder As String sFolder = "C:\NewFolder" If Dir(sFolder, vbDirectory) = "" Then MkDir sFolder -- Regards, Nigel "MarkS" wrote in message ... Hi, I need to test if a directory exists and if not create it. All I can think of is to use on error and try and open it, they create a new directory if it fails. Any sugestions of a more elegant way |
Testing for a directory
Just create it with error warp
On Error Resume Next MkDir myDir On Error Goto 0 -- __________________________________ HTH Bob "MarkS" wrote in message ... Hi, I need to test if a directory exists and if not create it. All I can think of is to use on error and try and open it, they create a new directory if it fails. Any sugestions of a more elegant way |
Testing for a directory
Thanks that work just great
"Nigel" wrote: This works for me..... Dim sFolder As String sFolder = "C:\NewFolder" If Dir(sFolder, vbDirectory) = "" Then MkDir sFolder -- Regards, Nigel "MarkS" wrote in message ... Hi, I need to test if a directory exists and if not create it. All I can think of is to use on error and try and open it, they create a new directory if it fails. Any sugestions of a more elegant way |
All times are GMT +1. The time now is 11:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com