方法存在且无法识别......“子或函数未定义vba”

时间:2016-01-15 09:24:26

标签: excel vba excel-vba

我有一个名为“UsefulStuff”的模块,它有一个函数:

Public Sub SuspendUpdating(message As String)
    Application.StatusBar = message
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
    Application.Cursor = xlWait
End Sub

当我打电话时,这是另一个模块“modJira”:

Public Sub ImportFromJira()

    Dim resultXml As MSXML2.DOMDocument, resultNode As IXMLDOMElement


    Dim nodeContainer As IXMLDOMElement
    Dim rowCount As Integer, colCount As Integer
    Dim fixVersionString As String
    Dim dumpRange As Range, tempValue As Variant

    'Dim usefulStuff As New usefulStuff

    Call SuspendUpdating("Getting data from Jira...")

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

注释掉的行

'Dim usefulStuff As New usefulStuff

表示usefulStuff模块。如果是这种情况,那么您将收到您提到的错误消息。

修复方法是取消注释掉该行,然后调用sub作为方法调用:

Dim usefulStuff As New usefulStuff

usefullStuff.SuspendUpdating "Getting data from Jira..."

如果这不能解决问题,我的猜测就是它在其他工作簿中。假设工作簿已打开并命名为Mystery.xlsm,则以下行应该起作用

Application.Run "Mystery.xlsm!SuspendUpdating", "Getting data from Jira..."