Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error Checking for Duplicates in List | Excel Worksheet Functions | |||
How can I use spell checking in a protected worksheet? | Excel Worksheet Functions | |||
Checking for duplicates - think this is simple | Excel Discussion (Misc queries) | |||
Checking names on correct line across sheets | Excel Worksheet Functions | |||
Checking Winning Numbers in the Lottery. | Excel Discussion (Misc queries) |