Function DetectCD() As Boolean
On Error GoTo ErrHan
Dir "D:\", vbDirectory
DetectCD = True
Exit Function
ErrHan:
DetectCD = False
End Function
Private Sub Timer1_Timer()
If DetectCD() Then
MsgBox "There is a CD in Drive D!"
Timer1.Enabled = False
Exit Sub
Else
'No CD
End If
End Sub