Now that I've added this error handling code, when I export to Excel it flashes up on screen then quickly disappears. If I comment out the new code, the Excel export works fine. What gives? This works in Access.

After I dimmed my variables, I wrote this:
VB Code:
  1. On Error GoTo CreateExcelSH_Err

Then at the bottom of the sub I wrote this:

VB Code:
  1. CreateExcelSH_Exit:
  2.     Call LoadCaption(False)
  3.     For i = 0 To UBound(objRSArray)
  4.         If objRSArray(i).State = 1 Then
  5.             objRSArray(i).Close
  6.         End If
  7.     Next i
  8.     Erase objRSArray
  9.     Erase xlChartArray
  10.     Set xlSheet = Nothing
  11.     Set xlBook = Nothing
  12.         xlApp.DisplayAlerts = False
  13.         xlApp.Quit
  14.         xlApp.DisplayAlerts = True
  15.     Set xlApp = Nothing
  16.     Exit Sub
  17.  
  18. CreateExcelSH_Err:
  19.     Select Case Err.Number
  20.         Case 1004
  21.             MsgBox "Excel cannot draw graphs due to a lack of data.  Please contact the Protection MI team."
  22.             Resume CreateExcelSH_Exit
  23.         Case Else
  24.             MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
  25.             Resume CreateExcelSH_Exit
  26.     End Select

I'm pretty new at error handling so I really have no idea what I'm doing.