Guessing Runtime Error in VBA for Excel

  Desert Andy 10:12 11 Mar 2005
Locked

I am writing a program which lets a user press a button and the program automatically saves the Excel workbook to a floppy disc. Although I have promted the used to put a floppy disc into the computer, I would like the program not to crash if he doesn't.
I know the error code will be a runtime error '1004' - Microsoft Office Excel cannot access the file 'A'. Is there any way of telling the program if it gets this code not to crash.

Thanks for your help in advance

  VoG II 10:19 11 Mar 2005

.
Dim oFilesysObject As Object
.
.
.
Set oFilesysObject = CreateObject("SCRIPTING.FILESYSTEMOBJECT")

'Check that drive A is ready

If oFilesysObject.GetDrive("A:\").IsReady = False Then

MsgBox "Drive A is not ready. Please insert a floppy disk."

Exit Sub

End If

  VoG II 10:21 11 Mar 2005

Formatting to pot.

Dim oFilesysObject As Object
.
.
.

Set oFilesysObject = CreateObject("SCRIPTING.FILESYSTEMOBJECT")

'Check that drive A is ready

If oFilesysObject.GetDrive("A:\").IsReady = False Then

MsgBox "Drive A is not ready. Please insert a floppy disk."

Exit Sub

End If

  Desert Andy 10:35 11 Mar 2005

Thanks for your help, swift and correct as always. Very much appreciate your efforts.
Andy

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

HP Envy x2 review: Hands-on

Iconic New York graphic designer Milton Glaser on his uplifting new subway posters

New iMac Pro release date, UK price & specs rumours

Comment suivre le parcours du père Noël ?