checking for drive
I think you have all you need.
Option Explicit
Function DoesPathExist(myPath As String) As Boolean
Dim TestStr As String
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If
TestStr = ""
On Error Resume Next
TestStr = Dir(myPath & "nul")
On Error GoTo 0
DoesPathExist = CBool(TestStr < "")
End Function
sub testme01()
dim myParentFolder as string
dim myFolder as string
myparentfolder = "U:\" 'something that I know exists
if doespathexist(myparentfolder) then
'keep going using U:
else
'switch to the C: drive
myparentfolder = "C:\"
end if
on error resume next
mkdir myparentfolder & "US 49"
mkdir myparentfolder & "US 49" & "\form 1257"
on error goto 0
myfolder = myparentfolder & "US 49" & "\form 1257"
'and use myfolder in the rest of your code.
end sub
========
untested, uncompiled--watch for typos.
jnf40 wrote:
Dave,
Ill try this again as far as explaining everything I am wanting to do, I
think I may be confusing myself more than anything, but here goes¦
I want to check to see if drive U: is valid, if so then I want to check
for directory US 49, if it is there fine if not create it. If directory US
49 is there then I want to check for sub directory 1257 Forms, if it is
there then my file would save there, if it is not there then it would create
the sub directory 1257 Forms then save my file there.
Now if drive U: is not a valid drive then it would check, create, and save
everything as above in drive C: So when all is finished I should have one
of the following paths:
U:\US 49\1257 Forms\my file if U: is a valid drive or
C:\US 49\1257 Forms\my file if drive U: is not a valid drive.
I have it now where it will do everything but check for and create the sub
directory. I hope I havent muddied the waters more, I appreciate your
patience and knowledge.
--
Dave Peterson
|