Excel XP & Win XP
How can I determine if a specific folder, say "C:\The Folder", exists?
I have an OP who will be sending some files, and the code to place the files
in that folder, to some people. Thanks for your time. Otto

Re: Does the folder exist? by Tim

Tim
Sat Mar 15 14:12:47 CDT 2008

Dir()

Tim

"Otto Moehrbach" <moehrbachoextra@bellsouth.net> wrote in message
news:OKs466shIHA.5204@TK2MSFTNGP02.phx.gbl...
> Excel XP & Win XP
> How can I determine if a specific folder, say "C:\The Folder", exists?
> I have an OP who will be sending some files, and the code to place the
> files in that folder, to some people. Thanks for your time. Otto
>



RE: Does the folder exist? by JLGWhiz

JLGWhiz
Sat Mar 15 14:16:00 CDT 2008

This is right out of VBA help file.

Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
End Sub

If you don't want the whole list you could modifiy it to say:

For Each fl in fc
If fl.name = "ObjectFileName" Then
MsgBox "File Is There"
Else
MsgBox "Not In This Bunch"
End If
Next

"Otto Moehrbach" wrote:

> Excel XP & Win XP
> How can I determine if a specific folder, say "C:\The Folder", exists?
> I have an OP who will be sending some files, and the code to place the files
> in that folder, to some people. Thanks for your time. Otto
>
>
>

Re: Does the folder exist? by Dave

Dave
Sat Mar 15 15:10:32 CDT 2008

Dim TestStr as string
TestStr = ""
on error resume next
teststr = dir("c:\the folder\nul")
on error goto 0

if teststr = "" then
'doesn't exist
else
'exists
end if

==========
But maybe you don't have to check. Maybe it would be enough to just create the
folder (ignoring any error if the folder is already there):

on error resume next
mkdir "C:\the folder"
on error goto 0



Otto Moehrbach wrote:
>
> Excel XP & Win XP
> How can I determine if a specific folder, say "C:\The Folder", exists?
> I have an OP who will be sending some files, and the code to place the files
> in that folder, to some people. Thanks for your time. Otto

--

Dave Peterson

Re: Does the folder exist? by RB

RB
Sat Mar 15 18:58:41 CDT 2008

Function FolderExists(strFolderPath As String) As Boolean
On Error Resume Next
If Len(strFolderPath) > 0 Then
FolderExists = ((GetAttr(strFolderPath) And vbDirectory) > 0)
Err.Clear
End If
End Function


RBS


"Otto Moehrbach" <moehrbachoextra@bellsouth.net> wrote in message
news:OKs466shIHA.5204@TK2MSFTNGP02.phx.gbl...
> Excel XP & Win XP
> How can I determine if a specific folder, say "C:\The Folder", exists?
> I have an OP who will be sending some files, and the code to place the
> files in that folder, to some people. Thanks for your time. Otto
>


Re: Does the folder exist? by Otto

Otto
Sun Mar 16 10:04:45 CDT 2008

Dave
Thanks for that but I have to show my ignorance. It seems to me that
your code is checking for the existence of a folder "nul" as a subfolder to
the folder "the folder". If this is so then "teststr" will be "" even if
"the folder" exists, since the folder "nul" doesn't exist. Did I jump the
track somewhere? Thanks again for your time. Otto
"Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
news:47DC2D38.BF944366@verizonXSPAM.net...
> Dim TestStr as string
> TestStr = ""
> on error resume next
> teststr = dir("c:\the folder\nul")
> on error goto 0
>
> if teststr = "" then
> 'doesn't exist
> else
> 'exists
> end if
>
> ==========
> But maybe you don't have to check. Maybe it would be enough to just
> create the
> folder (ignoring any error if the folder is already there):
>
> on error resume next
> mkdir "C:\the folder"
> on error goto 0
>
>
>
> Otto Moehrbach wrote:
>>
>> Excel XP & Win XP
>> How can I determine if a specific folder, say "C:\The Folder",
>> exists?
>> I have an OP who will be sending some files, and the code to place the
>> files
>> in that folder, to some people. Thanks for your time. Otto
>
> --
>
> Dave Peterson



Re: Does the folder exist? by Dave

Dave
Sun Mar 16 11:21:14 CDT 2008

There are DOS devices that "exist" for every folder:

PRN (Printer)
CON (Console)
NUL (Null)
LPTx (Printer)
AUX (Auxillary)
COMx (Serial)

If the device doesn't exist, then the folder doesn't exist.

Try it and you'll see.

Otto Moehrbach wrote:
>
> Dave
> Thanks for that but I have to show my ignorance. It seems to me that
> your code is checking for the existence of a folder "nul" as a subfolder to
> the folder "the folder". If this is so then "teststr" will be "" even if
> "the folder" exists, since the folder "nul" doesn't exist. Did I jump the
> track somewhere? Thanks again for your time. Otto
> "Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
> news:47DC2D38.BF944366@verizonXSPAM.net...
> > Dim TestStr as string
> > TestStr = ""
> > on error resume next
> > teststr = dir("c:\the folder\nul")
> > on error goto 0
> >
> > if teststr = "" then
> > 'doesn't exist
> > else
> > 'exists
> > end if
> >
> > ==========
> > But maybe you don't have to check. Maybe it would be enough to just
> > create the
> > folder (ignoring any error if the folder is already there):
> >
> > on error resume next
> > mkdir "C:\the folder"
> > on error goto 0
> >
> >
> >
> > Otto Moehrbach wrote:
> >>
> >> Excel XP & Win XP
> >> How can I determine if a specific folder, say "C:\The Folder",
> >> exists?
> >> I have an OP who will be sending some files, and the code to place the
> >> files
> >> in that folder, to some people. Thanks for your time. Otto
> >
> > --
> >
> > Dave Peterson

--

Dave Peterson

Re: Does the folder exist? by Otto

Otto
Sun Mar 16 17:15:09 CDT 2008

Thanks Dave. Every time I cross paths with you I learn something. Otto
"Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
news:47DD48FA.2E7B33CB@verizonXSPAM.net...
> There are DOS devices that "exist" for every folder:
>
> PRN (Printer)
> CON (Console)
> NUL (Null)
> LPTx (Printer)
> AUX (Auxillary)
> COMx (Serial)
>
> If the device doesn't exist, then the folder doesn't exist.
>
> Try it and you'll see.
>
> Otto Moehrbach wrote:
>>
>> Dave
>> Thanks for that but I have to show my ignorance. It seems to me that
>> your code is checking for the existence of a folder "nul" as a subfolder
>> to
>> the folder "the folder". If this is so then "teststr" will be "" even if
>> "the folder" exists, since the folder "nul" doesn't exist. Did I jump
>> the
>> track somewhere? Thanks again for your time. Otto
>> "Dave Peterson" <petersod@verizonXSPAM.net> wrote in message
>> news:47DC2D38.BF944366@verizonXSPAM.net...
>> > Dim TestStr as string
>> > TestStr = ""
>> > on error resume next
>> > teststr = dir("c:\the folder\nul")
>> > on error goto 0
>> >
>> > if teststr = "" then
>> > 'doesn't exist
>> > else
>> > 'exists
>> > end if
>> >
>> > ==========
>> > But maybe you don't have to check. Maybe it would be enough to just
>> > create the
>> > folder (ignoring any error if the folder is already there):
>> >
>> > on error resume next
>> > mkdir "C:\the folder"
>> > on error goto 0
>> >
>> >
>> >
>> > Otto Moehrbach wrote:
>> >>
>> >> Excel XP & Win XP
>> >> How can I determine if a specific folder, say "C:\The Folder",
>> >> exists?
>> >> I have an OP who will be sending some files, and the code to place the
>> >> files
>> >> in that folder, to some people. Thanks for your time. Otto
>> >
>> > --
>> >
>> > Dave Peterson
>
> --
>
> Dave Peterson



Re: Does the folder exist? by Dana

Dana
Tue Mar 18 04:07:17 CDT 2008

Just another of many...

Function IsFolder(S As String) As Boolean
IsFolder = CreateObject("Scripting.FileSystemObject").FolderExists(S)
End Function

--
HTH
Dana DeLouis


"Otto Moehrbach" <moehrbachoextra@bellsouth.net> wrote in message
news:OKs466shIHA.5204@TK2MSFTNGP02.phx.gbl...
> Excel XP & Win XP
> How can I determine if a specific folder, say "C:\The Folder", exists?
> I have an OP who will be sending some files, and the code to place the
> files in that folder, to some people. Thanks for your time. Otto


Re: Does the folder exist? by Otto

Otto
Tue Mar 18 07:05:37 CDT 2008

Thanks Dana, that's short and sweet. Otto
"Dana DeLouis" <ddelouis@bellsouth.net> wrote in message
news:%23kjg7dNiIHA.5160@TK2MSFTNGP05.phx.gbl...
> Just another of many...
>
> Function IsFolder(S As String) As Boolean
> IsFolder = CreateObject("Scripting.FileSystemObject").FolderExists(S)
> End Function
>
> --
> HTH
> Dana DeLouis
>
>
> "Otto Moehrbach" <moehrbachoextra@bellsouth.net> wrote in message
> news:OKs466shIHA.5204@TK2MSFTNGP02.phx.gbl...
>> Excel XP & Win XP
>> How can I determine if a specific folder, say "C:\The Folder", exists?
>> I have an OP who will be sending some files, and the code to place the
>> files in that folder, to some people. Thanks for your time. Otto
>