Hi!
Can anyone please help me on the following issue:
I need to know how can I check if a folder exist (I have the full path, let's say D:\Temp).
Thanks in advance,
Chris
Hi!
Can anyone please help me on the following issue:
I need to know how can I check if a folder exist (I have the full path, let's say D:\Temp).
Thanks in advance,
Chris
Hi
Try this
Sub TestDirectory()
Dim Dirname As String
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Dirname = "C:\MyDir"
If Not fs.FolderExists(Dirname) Then
MsgBox "not Exist"
Else
MsgBox "Exist"
End If
End Sub
--
Regards Ron de Bruin
http://www.rondebruin.nl
"loopoo" <[email protected]> wrote in message
news:[email protected]...
>
> Hi!
>
> Can anyone please help me on the following issue:
> I need to know how can I check if a folder exist (I have the full path,
> let's say D:\Temp).
>
> Thanks in advance,
> Chris
>
>
> --
> loopoo
> ------------------------------------------------------------------------
> loopoo's Profile: http://www.excelforum.com/member.php...o&userid=28792
> View this thread: http://www.excelforum.com/showthread...hreadid=491380
>
Thanks for your help, Ron.
Someone else helped me first with thie solution on another forum:
Function FolderExists(strPath) As Boolean
On Error Resume Next
ChDir strPath
If Err.Number <> 76 Then
FolderExists = True
Else
FolderExists = False
End If
End Function
I think yours is good too.
Once again,
Thanks for your help.
Chris
Here is a function that you can use
'-----------------------------------------------------------------
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
(remove nothere from the email address if mailing direct)
"loopoo" <[email protected]> wrote in
message news:[email protected]...
>
> Hi!
>
> Can anyone please help me on the following issue:
> I need to know how can I check if a folder exist (I have the full path,
> let's say D:\Temp).
>
> Thanks in advance,
> Chris
>
>
> --
> loopoo
> ------------------------------------------------------------------------
> loopoo's Profile:
http://www.excelforum.com/member.php...o&userid=28792
> View this thread: http://www.excelforum.com/showthread...hreadid=491380
>
Thanks for your help, Bob!
Chris
Ron's solution is better because it does not change the current folder.
--
Jim
"loopoo" <[email protected]> wrote in
message news:[email protected]...
|
| Thanks for your help, Ron.
|
| Someone else helped me first with thie solution on another forum:
|
| Function FolderExists(strPath) As Boolean
|
| On Error Resume Next
|
| ChDir strPath
| If Err.Number <> 76 Then
| FolderExists = True
| Else
| FolderExists = False
| End If
|
| End Function
|
| I think yours is good too.
|
| Once again,
| Thanks for your help.
|
| Chris
|
|
| --
| loopoo
| ------------------------------------------------------------------------
| loopoo's Profile:
http://www.excelforum.com/member.php...o&userid=28792
| View this thread: http://www.excelforum.com/showthread...hreadid=491380
|
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks