aziz rasul
Active member
- Local time
- Today, 23:20
- Joined
- Jun 26, 2000
- Messages
- 1,935
I have extracted the following code from online help (Drives Property). Online help suggests that even are no media in any of the drives, the code should work. But it doesn't.
How do I amend the code so that, for example there is no floppy disk in the A:\ drive, the code wil recognise that the drive exists and not cause an error saying that "Disk not ready".
Note that the code may be used on other machines which potentially will differenr drives e.g. 2 CD drives.
Public Function FolderInformation(strFolderName As String)
Dim fso As Object
Dim f As Object
Dim Drive_Message As String
Dim dc As Object
Dim n As String
Dim d As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strFolderName)
Set dc = fso.Drives
For Each d In dc
Drive_Message = Drive_Message & d.DriveLetter & " - "
If d.DriveType = 3 Then
n = d.ShareName
Else
n = d.VolumeName
End If
Drive_Message = Drive_Message & n & vbCrLf
Next
MsgBox Drive_Message, vbOKOnly, "Drive List"
End Function
How do I amend the code so that, for example there is no floppy disk in the A:\ drive, the code wil recognise that the drive exists and not cause an error saying that "Disk not ready".
Note that the code may be used on other machines which potentially will differenr drives e.g. 2 CD drives.
Public Function FolderInformation(strFolderName As String)
Dim fso As Object
Dim f As Object
Dim Drive_Message As String
Dim dc As Object
Dim n As String
Dim d As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strFolderName)
Set dc = fso.Drives
For Each d In dc
Drive_Message = Drive_Message & d.DriveLetter & " - "
If d.DriveType = 3 Then
n = d.ShareName
Else
n = d.VolumeName
End If
Drive_Message = Drive_Message & n & vbCrLf
Next
MsgBox Drive_Message, vbOKOnly, "Drive List"
End Function