English

Error: Error 13: Type mismatch

Error Message


[O-Image] Singapore
This article was contributed by Esri Singapore.

VBA code that was created in ArcGIS 9.3 may return the following error in ArcGIS 10.

"Error 13: Type mismatch"

Cause

When code created with ArcGIS 9.3 contains the following lines and is run in ArcGIS 10, a mismatch error is returned.

Code:
Public Sub Run()

Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument

Dim pPageLayout As IPageLayout
Set pPageLayout = pMxDoc.PageLayout

Dim pPage As IPage
Set pPage = pPageLayout.Page '** error occurs here **

End Sub

Solution or Workaround

  1. Verify that the references to the esriCarto and esriCartoUI libraries have been given from Tools > References in the VB editor.
    They should be pointing to '<ArcGIS installation folder>\com\esriCarto.olb' and '<ArcGIS installation folder>\com\esriCartoUI.olb', respectively.

    If needed, correct the library references to these paths (default setting).
  2. If the error continues to occur after verifying the reference libraries, fully qualify the interfaces in the code.

    Code:
    Dim pPageLayout As esriCarto.IPageLayout

    Set pPageLayout = pMxDocument.PageLayout

    Dim pPage As esriCarto.IPage

    Set pPage = pPageLayout.Page