View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default verify a path exists

Man, I hope you're not 80.

The first 9 years would have been tough!

JLGWhiz wrote:

Thanks Dave, I knew it was not that hard, but my 71 year old brain don't
function too well sometimes.

"Dave Peterson" wrote:

I do this:

Dim TestStr as string

teststr = ""
on error resume next
teststr = dir("c:\windows\media\nul")
on error goto 0

if teststr = "" then
'doesn't exist
else
'it's there
end if

====
But this'll work, too:

If CreateObject("Scripting.FileSystemobject") _
.folderexists("C:\windows\media") = True Then
MsgBox "Yep"
Else
MsgBox "nope"
End If

JLGWhiz wrote:

This is probably so simple that I am overlooking it. I want to write code as
an If...Then method to verify that a certain path exists. Let's say
"C:\Windows|Media".
I tried the Exists( What ) method but could not find an object that VBA
liked. Make me feel stupid and show me the code. Thanks.


--

Dave Peterson


--

Dave Peterson