Vba 运行时错误“424”-需要对象

Vba 运行时错误“424”-需要对象,vba,ms-word,Vba,Ms Word,我正在处理一个VBA-Word表单,我试图使它成为当用户选择一个复选框时,他们输入一个对应于该复选框的值。我对VBA没有太多的经验,因为我通常从不使用这种东西。因此,当我运行程序时,我会得到作为标题发布的错误代码 'When checked, number of days must be > 0. If chkOnLine.Value = True Then If txtOnLine.Text <> "" Then blnTemp = IsNumeric

我正在处理一个VBA-Word表单,我试图使它成为当用户选择一个复选框时,他们输入一个对应于该复选框的值。我对VBA没有太多的经验,因为我通常从不使用这种东西。因此,当我运行程序时,我会得到作为标题发布的错误代码

'When checked, number of days must be > 0.
If chkOnLine.Value = True Then
    If txtOnLine.Text <> "" Then
        blnTemp = IsNumeric(txtOnLine.Text)
        If Not blnTemp Then
            blnError = True
            strError = "On-line sessions must be numeric."
            GoTo EndError
        End If
        If txtOnLine.Text <= 0 Then
            blnError = True
            strError = "Value must be greater than zero."
            GoTo EndError
        End If
    End If
End If

哪一行代码触发了错误?您的代码缺少上下文。我的直觉是chkOnLine或txtOnLine都没有正确设置,它们似乎是片段中唯一需要对象的地方,但这些变量是声明的,希望在您显示的代码之外给出值。