Type not supported in Visual Basic

Not all types are supported in Visual Basic. This error has the following cause and solution:

  • You tried to use a type in your program that has no equivalent in Visual Basic for Applications. For example, Visual Basic has no pointer or unsigned integer type, so if you try to create a variable of one of those types from an object library, this error occurs.

    In the following example, even though Rainbow may be a valid structure, Visual Basic can't create a variable of that type if it contains a type Visual Basic doesn't recognize:

      Dim MyVar As Rainbow    ' Causes error. 
    

    If the type is a valid parameter type for a function in an object library, this error means only that you can't create a variable of that type in your own code. Although you can't always declare variables with a data type specified in an object's documentation, there is often a Visual Basic equivalent.

    For example, although Visual Basic has no pointer type, you can pass a pointer to a function to an API function by using the AddressOf operator. Also, check the Variant type's subtypes. You can often use them as equivalents of types not offered directly in Visual Basic. In some cases, however, Visual Basic simply has no equivalent. For example, data pointers aren't available.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.