ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removable drives (https://www.excelbanter.com/excel-programming/287675-removable-drives.html)

marks

Removable drives
 
Hi,
Is there a piece of code to check that a removable drive
is there or not.

Thanks MarkS

Tim Williams[_3_]

Removable drives
 

Couple of functions you should be able to adapt

Tim


From:
http://msdn.microsoft.com/library/de...us/script56/ht
ml/jscoldrives.asp

Function ShowDriveList
Dim fso, d, dc, s, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = 3 Then '
n = d.ShareName
ElseIf d.IsReady Then
n = d.VolumeName
Else
n = "[Drive not ready]"
End If
s = s & n & vbcrlf
Next
ShowDriveList = s
End Function

Function ShowDriveType(drvpath)
Dim fso, d, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(drvpath)
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
ShowDriveType = "Drive " & d.DriveLetter & ": - " & t
End Function





"MarkS" wrote in message
...
Hi,
Is there a piece of code to check that a removable drive
is there or not.

Thanks MarkS





All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com