ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking to see if Folder exists (https://www.excelbanter.com/excel-programming/277833-checking-see-if-folder-exists.html)

Dan[_25_]

Checking to see if Folder exists
 
In my macro I need to check to see if a folder exists b/4 I create one. What
command should I use? Does anyone have some quick code to check if a folder
exists and if not, create it?

Dan



steve

Checking to see if Folder exists
 
Dan,

Ron posted this on the 17th...

Sub MakeDirectory()
Dim Dirname As String
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Dirname = "C:\Data"
If Not fs.FolderExists(Dirname) Then
fs.CreateFolder Dirname
' your code
Else
' your code
End If
End Sub


--
Regards Ron de Bruin


--
sb
"Dan" wrote in message
...
In my macro I need to check to see if a folder exists b/4 I create one.

What
command should I use? Does anyone have some quick code to check if a

folder
exists and if not, create it?

Dan





Dave Peterson[_3_]

Checking to see if Folder exists
 
On error resume next
mkdir "C:\test"
on error goto 0

(just ignore the error if it's already there.)



Dan wrote:

In my macro I need to check to see if a folder exists b/4 I create one. What
command should I use? Does anyone have some quick code to check if a folder
exists and if not, create it?

Dan


--

Dave Peterson



All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com