LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Checking for Duplicates in List bman342 Excel Worksheet Functions 2 June 29th 06 11:15 AM
How can I use spell checking in a protected worksheet? Deb from MA Excel Worksheet Functions 1 April 24th 06 06:40 PM
Checking for duplicates - think this is simple [email protected] Excel Discussion (Misc queries) 9 February 27th 06 09:32 PM
Checking names on correct line across sheets Ali Excel Worksheet Functions 5 January 17th 06 07:24 AM
Checking Winning Numbers in the Lottery. Ann Excel Discussion (Misc queries) 4 May 18th 05 10:55 AM


All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"