VB and VBA Users Source Code: Determine if the CD Rom drive contains media
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Determine if the CD Rom drive contains media
By:
Carl Graham
Email (spam proof):
Email the originator of this post
Date:
Wednesday, December 13, 2000
Hits:
740
Category:
Files/Directories/IO
Article:
To quickly determine if the CD Rom drive contains media, use the Scripting Runtime library's IsReady property for the Drive object. For CD Rom drives, this property returns True only if the drive contains the appropriate media. To take advantage of this handy property, add a Reference to Microsoft Scripting Runtime library (scrrun.dll). Next, create a Drive variable based on the CD Rom drive, and test the IsReady property, as shown below: Dim FSO As FileSystemObject Dim aDrive As Drive Set FSO = New FileSystemObject For Each aDrive In FSO.Drives If aDrive.DriveType = CDRom And aDrive.IsReady = False Then MsgBox "Please enter a CD." Exit For ElseIf aDrive.DriveType = CDRom Then MsgBox aDrive.VolumeName Exit For End If Next Set FSO = Nothing
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder