找不到VBA错误424对象,但我有对象

时间:2016-08-01 14:41:51

标签: excel vba excel-vba

我对VBA很陌生,但学得很快。我将这个名为AddRoute55的用户窗体和一个CommandButton放在我的工作表中以激活它。

CommandButton 背后的代码是:

Private Sub Route55Button_Click()

AddRoute55.Show

End Sub

userformcode为:

Private Sub UserForm_Initialize()

'Empty Status
StatusBox.Clear

'Fill StatusBox
With StatusBox
    .AddItem "Received"
    .AddItem "Returned to PM"
    .AddItem "In Progress"
    .AddItem "On Hold"
    .AddItem "Complete"
    .AddItem "Closed"
    .AddItem "RFC"
End With


'Empty BTBox
BTBox.Clear

'Fill BTBox
With BTBox
    .AddItem "Run"
    .AddItem "Change"
End With

'Empty DomainBox
DomainBox.Clear

'Fill DomainBox
With DomainBox
    .AddItem "AMS NL"
    .AddItem "AMS INT"
    .AddItem "EUS"
    .AddItem "IPS"
    .AddItem "NGC"
    .AddItem "Office"
    .AddItem "SM"
End With

'Empty AIMSBox
AIMSBox.Value = ""

'Empty ProjectCoedeBox
ProjectCodeBox.Value = ""

'Empty PMBox
PMBox.Value = ""

'Empty POBox
POBox.Value = ""

'Empty VendorBox
VendorBox.Value = ""

'Set No FTR as default
FTRButton2.Value = True

'Empty OrderReceivedBox
OrderReceivedBox.Value = ""

'Empty OrderProcessedBox
OrderProcessedBox.Value = ""

'Empty SSDMBox
SSDMBox.Value = ""

'Empty P2PBox
P2PBox.Value = ""

'Empty CustomerBox
CustomerBox.Value = ""

'Empty PMABox
PMABox.Value = ""

'Empty SPBox
SPBox.Value = ""


End Sub

userform本身在属性中称为AddRoute55。但是当我按下命令按钮时,我看到错误424,找不到对象,它引用了AddRoute55.Show的行。我究竟做错了什么?提前谢谢!

1 个答案:

答案 0 :(得分:1)

您确定,这是名称而不是标题吗?

如果您的代码不起作用,请尝试以下操作:

Private Sub Route55Button_Click()    
     UserForm1.Show    
End Sub

您可以通过在设计模式下右键单击VBA编辑器中的Userform来更改Userform的name