Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,650
- Office Version
- 365
- 2016
- Platform
- Windows
How can I best adapt the following code to trap when the destination drive is unavailable? Sometimes, this drive (O:\) goes offline so if this code is run, an error is triggered.
Code:
Public Sub open_folder(txt_model As String)
Dim modelini As String, fldini As String
Dim fldMaster As String, fldPath As String
Dim ffound ' As String
Dim response
fldMaster = "O:\IFM\"
If Dir(fldMaster, vbDirectory) = "" Then
MkDir fldMaster
End If
If Right(txt_model, 1) = "." Then txt_model = Left(txt_model, (Len(txt_model) - 1))
modelini = Left(txt_model, 1)
fldini = fldMaster & modelini & "\"
If Dir(fldini, vbDirectory) = "" Then
MkDir fldini
End If
fldPath = fldini & txt_model & "\"
If Dir(fldPath, vbDirectory) = "" Then
MkDir fldPath
MsgBox "Folder for " & txt_model & " created." & Chr(13) & fldPath, vbInformation, "SUCCESS"
End If
Shell "explorer.exe /root," & fldPath, vbNormalFocus
End Sub