Implementing the ErrorHandler

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Developer's Guide

Implementing the ErrorHandler

For the JumpStart application, you create the ErrorHandler by implementing the IVBSAXErrorHandler interface.

To create the ErrorHandlerImpl class

  1. On the Project menu, click Add Class Module.
  2. In the Add Class Module dialog box, double-click Class Module.
  3. On the View menu, select Properties Window.
  4. In the Properties Window, enter "ErrorHandlerImpl" for the Name property.

To implement the ErrorHandlerImpl class

  1. In the Class Window, type "Implements", press the spacebar, and then double-click IVBSAXErrorHandler from the drop-down list that appears.
  2. In the Object drop-down list on the left side of the Class Window, select IVBSAXErrorHandler.
  3. In the Procedure drop-down list on the right side of the Class Window, select a method or property to add to the class.
  4. Add the desired code to the selected method or property.
  5. Repeat steps 3 and 4 until you have added the desired methods and properties.
    Note   If you have trouble implementing methods and procedures for the ErrorHandlerImpl class, refer back to Implementing the ContentHandler to see how methods and properties were implemented for the ContentHandlerImpl class.

Complete Code for the ErrorHandlerImpl Class

The following is the complete code for the ErrorHandlerImpl class of the JumpStart application.

Option Explicit

Implements IVBSAXErrorHandler


Private Sub IVBSAXErrorHandler_fatalError(ByVal lctr As IVBSAXLocator, _
                                          msg As String, _
                                          ByVal errCode As Long)
    Form1.Text2.text = Form1.Text2.text & "*** error *** " & msg
    
End Sub

Private Sub IVBSAXErrorHandler_error(ByVal lctr As IVBSAXLocator, _
                                     msg As String, ByVal errCode As Long)
End Sub

Private Sub IVBSAXErrorHandler_ignorableWarning( _
                                 ByVal oLocator As MSXML2.IVBSAXLocator, _
                                 strErrorMessage As String, _
                                 ByVal nErrorCode As Long)
End Sub

In the preceding code, only the fatalError method contains code for handling events. For this version of Microsoft® XML Core Services (MSXML) 5.0 for Microsoft Office, only the fatalError method is called for IVBSAXErrorHandler.