Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if floppy disk is in A drive

Status
Not open for further replies.

Numbers1

Technical User
Dec 27, 2003
34
US
I have created an Excel file in my application that I want to automatically copy to a floppy disk in the A drive. I have a message box (vbOK) come up instructing the user to insert a disk in the A drive but do not know how to check to see if it has been inserted before proceding with the copy feature in the program. Was looking at the GetDriveName function which returns "" if there is nothing in the drive but not sure how to write the code for this. Can you help?
Thanks, Numbers
 
Doesn't look like VBA On Error specifically recognises a "missing" disk. Try this code without a floppy in the drive :-

'-----------------------------------
Sub test()
On Error GoTo getout
ActiveWorkbook.SaveAs FileName:="A:\test.xls"
Exit Sub
'-------------------------------------
getout:
If Err.Number <> 0 Then
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
End If
End Sub
'-------------------------------------


Regards
BrianB
Use CupOfCoffee to speed up all windows applications
================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top