【问题标题】:"User-defined type not defined" for simple custom type简单自定义类型的“未定义用户定义类型”
【发布时间】:2011-01-13 20:15:45
【问题描述】:

在 Excel 2007 中,我在 VBA 中有以下非常简单的代码:

Public Type specType
    sb As Long
End Type


Private Sub MyButton_Click()
    Dim spec As specType

    '...
End Sub

单击按钮时,“Dim spec As specType”行出现“未定义用户定义类型”错误...为什么?我是否必须将我的用户定义类型移动到特殊位置?

【问题讨论】:

  • 您必须在模块中声明用户定义的类型。您展示的所有代码是否都放在一个模块中?

标签: vba excel user-defined-types


【解决方案1】:

原来类型必须在模块中的任何函数之前定义,否则它们根本不会被识别(不会给你一个错误)。

【讨论】:

  • 在任何函数或子程序之前。
猜你喜欢
  • 2023-03-09
  • 1970-01-01
  • 1970-01-01
  • 2017-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-25
  • 1970-01-01
相关资源
最近更新 更多