View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Does the folder exist?

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" wrote in message
...
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