One idea, using Dir(), could be to trap the failure to change to the E: drive (if it didn't exist) in an On Error Goto routine.
This isn't very elegant, however, so I'll post back when I've had a better idea.
I don't know whether you've tried it or not but try using the dir function with the vbdirectory attribute
dir("E:\",vbdirectory)
otherwise try using the filesystem object something like this.
Sub ShowDriveList
Dim fs, d, dc, s, n
Set fs = CreateObject("Scripting.FileSystemObject"
Set dc = fs.Drives
For Each d in dc
if d.driveletter = "E" then
found = true
end if
Next
MsgBox s
End Sub
Mark
The key to immortality is to make a big impression in this life!!
I see this code in another site. I tried and it works perfectly.
It returns true or false and works with dir or file.
Function AsfFichDir(stPath As String, Optional lngType As Long) As Integer
'To check for a file - AsfFichDir("c:\winnt\win.ini"
'To check for a Dir - AsfFichDir("c:\msoffice",vbdirectory)
On Error Resume Next
AsfFichDir = Len(Dir(stPath, lngType)) > 0
Function IsDriveReady(Optional DrvLetter As String = "A" As Boolean 'Function returns true if drive is ready
'and it stands to reason exists.
'Drive "A:" default drive
Dim fs, d, s
Set fs = CreateObject("Scripting.FileSystemObject"
Set d = fs.GetDrive(DrvLetter)
IsDriveReady = d.IsReady
End Function
dim bln as boolean
bln=IsDriveReady 'Check for drive "A:" (default)
if not IsDriveReady("D" then
exit sub
end if
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.