PC Review


Reply
Thread Tools Rate Thread

Does the folder exist?

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      15th Mar 2008
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


 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      15th Mar 2008
Dir()

Tim

"Otto Moehrbach" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      15th Mar 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
>
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      15th Mar 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
 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      15th Mar 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>


 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      16th Mar 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      16th Mar 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      16th Mar 2008
Thanks Dave. Every time I cross paths with you I learn something. Otto
"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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



 
Reply With Quote
 
Dana DeLouis
Guest
Posts: n/a
 
      18th Mar 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      18th Mar 2008
Thanks Dana, that's short and sweet. Otto
"Dana DeLouis" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Just another of many...
>
> Function IsFolder(S As String) As Boolean
> IsFolder = CreateObject("Scripting.FileSystemObject").FolderExists(S)
> End Function
>
> --
> HTH
> Dana DeLouis
>
>
> "Otto Moehrbach" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create folder or folder/subfolder if not exist Song Microsoft Access Getting Started 2 9th Aug 2008 12:36 PM
folder already exist? Jean Guillon Windows Vista Mail 7 11th Mar 2008 06:22 PM
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k Microsoft Excel Programming 6 11th Aug 2006 08:41 PM
Failed copying file '811114_asp51.dll' into QFE repository folder. repository folder {41B0394B-74D8-4CFD-86C0-BDCE45CE4728} does not exist. Zhang Hui Windows XP Embedded 1 4th Mar 2005 04:30 AM
Sent items folder not exist in personal folder. Copy of sent item. =?Utf-8?B?ZWJpemZt?= Microsoft Outlook Discussion 2 2nd Dec 2004 09:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:03 AM.