![]() |
check and create folder for saveas
how do you chech if a folder exists and create one on A: drive is it is not
there ? Please help a newbie- Thanks :-} |
check and create folder for saveas
Hi Sunil,
One way Sub Test() Dim sFolder As String sFolder = "C:\Mytest\New Dir" If Not FolderExists(sFolder) Then MkDir sFolder End If End Sub '----------------------------------------------------------------- Function FolderExists(Folder) As Boolean '----------------------------------------------------------------- Dim sFolder As String On Error Resume Next sFolder = Dir(Folder, vbDirectory) If sFolder < "" Then If (GetAttr(sFolder) And vbDirectory) = vbDirectory Then FolderExists = True End If End If End Function -- HTH RP "Sunil" wrote in message ... how do you chech if a folder exists and create one on A: drive is it is not there ? Please help a newbie- Thanks :-} |
check and create folder for saveas
If c:\mytest didn't exist, then I get an error when I try to make:
c:\mytest\new dir in one statement. Bob Phillips wrote: Hi Sunil, One way Sub Test() Dim sFolder As String sFolder = "C:\Mytest\New Dir" If Not FolderExists(sFolder) Then MkDir sFolder End If End Sub '----------------------------------------------------------------- Function FolderExists(Folder) As Boolean '----------------------------------------------------------------- Dim sFolder As String On Error Resume Next sFolder = Dir(Folder, vbDirectory) If sFolder < "" Then If (GetAttr(sFolder) And vbDirectory) = vbDirectory Then FolderExists = True End If End If End Function -- HTH RP "Sunil" wrote in message ... how do you chech if a folder exists and create one on A: drive is it is not there ? Please help a newbie- Thanks :-} -- Dave Peterson |
check and create folder for saveas
Just another idea...
s = "C:\Demo" With CreateObject("Scripting.FileSystemObject") If Not .FolderExists(s) Then .CreateFolder (s) End With -- Dana DeLouis Win XP & Office 2003 "Bob Phillips" wrote in message ... Hi Sunil, One way Sub Test() Dim sFolder As String sFolder = "C:\Mytest\New Dir" If Not FolderExists(sFolder) Then MkDir sFolder End If End Sub '----------------------------------------------------------------- Function FolderExists(Folder) As Boolean '----------------------------------------------------------------- Dim sFolder As String On Error Resume Next sFolder = Dir(Folder, vbDirectory) If sFolder < "" Then If (GetAttr(sFolder) And vbDirectory) = vbDirectory Then FolderExists = True End If End If End Function -- HTH RP "Sunil" wrote in message ... how do you chech if a folder exists and create one on A: drive is it is not there ? Please help a newbie- Thanks :-} |
All times are GMT +1. The time now is 07:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com