LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Error Handling of system codes

Problem: I want to create a backup of a workbook on open and feel there
are four possible error conditions to handle. Each should display a
different message to tell the user what is wrong.
1. disk full
2. disk write protected
3. file already open
4. file is read-only

I have an (partial) error handler designed but find that no matter
which condition actually exists always takes the Case Else path.
Sometimes err.number is "1004" while othertimes it is "0" (as seen in
the message box). code follows.

What am I doing wrong?

Sub Auto_open()

On Error GoTo ErrorHandler
If InStr(1, ThisWorkbook.Name, ".bck") < 1 Then
tmp = InStr(1, ThisWorkbook.Name, ".")
bckName = Left(ThisWorkbook.Name, tmp - 1) + ".bck"
ActiveWorkbook.SaveCopyAs (bckName)
End If
ErrorHandler:
Select Case Err.Number

Case 61

msg = "Disk full. Click Yes to continue without creating a backup."
msg = msg + "Otherwise click No to exit Excel."

response = MsgBox(msg, vbYesNo, "Warning: Disk Full")


If response = 6 Then Exit Sub
Application.Quit
Case Else

r = MsgBox("Error # :" & Err.Number & Err.Description, vbOKOnly)

End Select

End Sub

thanks in advance.....

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling Don Rouse Excel Programming 1 August 2nd 05 06:02 PM
Excel to create codes using the 321 system Mirsten Choiple Excel Worksheet Functions 5 May 13th 05 05:23 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error Handling bw Excel Programming 3 June 20th 04 06:43 PM
Error Handling AA2e72E[_2_] Excel Programming 0 April 27th 04 04:06 PM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"