Thread: ehandler
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default ehandler

On Tue, 10 Feb 2009 13:21:03 -0800, Oldjay
wrote:

I think the best way is with one error handler. Since you're looking for
certain errors, just trap those specifically

On Error Resume Next
quotenumber1 = InputBox("Please enter QUOTE file name to save to your C
drive & Server3", _
"X Technologies LLC", NUMBERSAVE)
QUOTE = "C:\Quick Quotes3\" & NUMBERSAVE & ".XLS"
ActiveWorkbook.SaveAs Filename:=QUOTE

On Error Goto ErrHandler

If ActiveWorkbook.FullName < QUOTE Then Err.Raise 9991

On Error Resume Next
QUOTE1 = "\\server3\jobs\estimate1\Quick Quotes3\" & NUMBERSAVE & ".XLS"
ActiveWorkbook.SaveAs Filename:=QUOTE1

On Error Goto ErrHandler

If ActiveWorkbook.Fullname < QUOTE Then Err.Raise 9992

ActiveWorkbook.Close
'End 6/09/08 revision

Application.Goto Reference:="InPutForm"
Range("AB2").Select

MainMenu.Show vbModeless
Exit Sub


ErrHandler:
Select Case Err.Number
Case 9991
MsgBox "You cancelled the save or an error has occured connecting to the
C:\Quick Quotes3\. Check your C: drive and try again ", vbCritical +
vbOKOnly, "File not saved!"

ActiveWorkbook.Close
Windows(MasterSheet).Activate
Sheets("Input").Select
MainMenu.Show vbModeless
Exit Sub

Case 9992
MsgBox "You cancelled the save or an error has occured connecting to the
Server3. Check your connection and try again ", vbCritical + vbOKOnly, "File
not saved!"
ActiveWorkbook.Close
Windows(MasterSheet).Activate
Sheets("Input").Select
MainMenu.Show vbModeless
Exit Sub

Windows(MasterSheet).Activate
Sheets("Input").Select
MainMenu.Show vbModeless


Case Else
MsgBox Err.Description
End Select
End Sub

--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com