Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Dec 2001
    Location
    Kent, UK
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatically picking the CD Rom drive (Win98SE Office 97)

    Using VBA, I'm trying to open Excel & Word docs from the CD drive. The CD disk will be transported to a number of different PCs. Is there any code that can automatically pick up the CD drive from Windows ? - or will I have to resort to asking the user for the CD drive letter ?

  2. #2
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically picking the CD Rom drive (Win98SE Office 97)

    I came across this:
    Retrieving Volume Information and checking if a CD is in the drive
    at vb.world, but it may be VB as opposed to VBA . . .

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Automatically picking the CD Rom drive (Win98SE Office 97)

    The following code will return the Drive Letter (e.g. D) of the first CD-ROM found on the system. It uses the FileSystemObject. <pre> Function GetCDROM()
    Dim oFso, oDrives, oDrive
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oDrives = fso.Drives
    For Each oDrive In oDrives
    With oDrive
    If .DriveType = 4 Then
    GetCDROM = .DriveLetter
    Set oDrives = Nothing
    Set oFso = Nothing
    Exit Function
    End If
    End With
    Next
    Set oDrives = Nothing
    Set oFso = Nothing
    End Function</pre>

    Andrew C

  4. #4
    New Lounger
    Join Date
    Dec 2001
    Location
    Kent, UK
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically picking the CD Rom drive (Win98SE Office 97)

    That did the trick, thanks very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •