简体   繁体   English

运行时错误'91'

[英]Run Time Error '91'

Run Time Error '91' : Object Variable or With Block not Set 运行时错误'91':对象变量或未设置块

My code is 我的代码是

Private Sub Workbook_Open()
  Dim MenuBar As CommandBarButton
  Set MenuBar = CommandBars(Standard).Controls(3)
  MsgBox MenuBar.Caption
End Sub

Please help me to resolve this error. 请帮我解决这个错误。

You have put Standard instead of "Standard" . 你已经把Standard而不是"Standard" And hence I always suggest to use Option Explicit . 因此我总是建议使用Option Explicit

If you don't use the " then Standard is treated as a variable. 如果你不使用"那么Standard被视为一个变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM