用户定义的类型未定义

您可在 Visual Basic 中创建自己的数据类型,但它们必须先在 Type...End Type 语句或之前注册的对象库类型库中定义。 此错误的原因及解决方案如下:

  • 您已尝试声明未定义数据类型的变量参数或您指定了未知或对象。

    模块中使用 Type 语句定义新的数据类型。 如果您尝试创建对类的引用,则类必须对项目可见。 如果您要在程序中引用类,则项目中必须具有指定名称的类模块。 检查类型名称或对象名称的拼写。

  • 您要声明的类型位于其他模块中,但已声明为 Private 。 将此类型的定义移到标准模块,此类型在其中可声明为 Public

  • The type is a valid type, but the object library or type library in which it is defined isn't registered in Visual Basic. Display the References dialog box, and then select the appropriate object library or type library. For example, if you don't check the Data Access Object in the References dialog box, types like Database, Recordset, and TableDef aren't recognized and references to them in code cause this error.

有关其他信息,选择有问题的项并按 F1(在 Windows 中)或 HELP(在 Macintosh 上)。

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。