Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am in need of some help with Error Handling. I am new to using VBA and
have found this site to be very helpful, but just cannot find enough information on error handling to make this make sense to me. My situation is as follows: I have a Scheduled task that opens a workbook containing the following code: AutoOpen Macro Sub Auto_Open() newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 3 waitTime = TimeSerial(newHour, newMinute, newSecond) Application.Wait waitTime SendKeys ("{TAB}") SendKeys ("~") On Error GoTo errhandler Workbooks.Open ("C:\Documents and Settings\dminor\Desktop\query\Dispatch Query.dqy") errhandler: If Err.Number = 1004 Then Application.DisplayAlerts = False Application.EnableEvents = False ActiveWorkbook.Close SaveChanges:=False Application.Quit End If Resume Next newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 10 waitTime = TimeSerial(newHour, newMinute, newSecond) Application.Wait waitTime Application.Run ("Personal.XLS!PriorityDispatch") Application.DisplayAlerts = True End Sub I have two issues with this code. The first is it only addresses the most common error, (error 1004), but every now and then I do see another type of error. The other issue is when I do experience the 1004 error Excel will close everything except my personal workbook. My questions are how I address all types of errors, and how I can close all of the workbooks. Any help would be appreciated. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error Handling | Excel Discussion (Misc queries) | |||
Error Handling | Excel Programming | |||
Error handling with a handling routine | Excel Programming | |||
error handling off?? | Excel Programming | |||
Error Handling | Excel Programming |