Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 4697|回复: 2

[已解决]CommandBar对象的Enabled属性的作用是什么?

[复制链接]
发表于 2011-5-29 12:04 | 显示全部楼层 |阅读模式
本帖最后由 爱疯 于 2011-5-29 12:05 编辑

Enabled  获取或设置用于指定是否启用了指定 CommandBar 的 Boolean 值。可读写。

  1. Sub MenuBar_Show()
  2.     Dim myNewBar As Object
  3.     Set myNewBar = CommandBars.Add(Name:="Custom1", Position:=msoBarFloating)
  4.     ' You must first enable your custom menu bar before you make it visible.
  5.     ' Enabling a menu bar adds it to the list of available menu bars on
  6.     ' the Customize dialog box.
  7.     ' Setting the menubar property to True replaces the built-in menu bar.
  8.     myNewBar.Enabled = True
  9.     myNewBar.Visible = True
  10. End Sub
复制代码

启用或注释myNewBar.Enabled = True,请问:区别在哪儿?谢谢!
最佳答案
2011-5-30 08:36
默认就是True,所以没区别。但是成为False之后就无法显示了
Sub MenuBar_Show()
    Dim myNewBar As Object
    Set myNewBar = CommandBars.Add(Name:="Custom1", Position:=msoBarFloating)
    ' You must first enable your custom menu bar before you make it visible.
    ' Enabling a menu bar adds it to the list of available menu bars on
    ' the Customize dialog box.
    ' Setting the menubar property to True replaces the built-in menu bar.
    myNewBar.Enabled = False
    myNewBar.Visible = True
End Sub
发表于 2011-5-30 08:36 | 显示全部楼层    本楼为最佳答案   
默认就是True,所以没区别。但是成为False之后就无法显示了
Sub MenuBar_Show()
    Dim myNewBar As Object
    Set myNewBar = CommandBars.Add(Name:="Custom1", Position:=msoBarFloating)
    ' You must first enable your custom menu bar before you make it visible.
    ' Enabling a menu bar adds it to the list of available menu bars on
    ' the Customize dialog box.
    ' Setting the menubar property to True replaces the built-in menu bar.
    myNewBar.Enabled = False
    myNewBar.Visible = True
End Sub
回复

使用道具 举报

 楼主| 发表于 2011-5-30 09:02 | 显示全部楼层
谢谢阿木!
我昨天试true和false都能看到显示出添加的"Custom1"。
怎么今早试,false就会从自定义对话框中看不到。但它还在,因为CommandBars("Custom1").Delete 是成功的。 .... 晕
看来endable=false,就是禁用它,学习了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-30 03:34 , Processed in 0.242376 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表