Excel精英培训网

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

[已解决]怎么定义?

[复制链接]
发表于 2013-6-27 12:23 | 显示全部楼层 |阅读模式
本帖最后由 sdada 于 2013-6-27 12:35 编辑

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Application.CommandBars("cell").Reset
End Sub
Private Sub Workbook_Open()
    Application.CommandBars("cell").Reset
    Set cma = Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, Before:=1)
    With cma
        .Caption = "设置字体格式和字体颜色"
        .OnAction = "字体颜色"
    End With
    Set cmb = Application.CommandBars("cell").Controls.Add(Type:=msoControlButton, Before:=1)
    With cmb
        .Caption = "设置单元格格式和填充颜色"
        .OnAction = "填充颜色"
    End With
End Sub
这个cma和cmb 定义为 CommandBarControl 还是 CommandBarbutton ???
最佳答案
2013-6-27 12:32
CommandBarControl 对象与 CommandBarButtonCommandBarComboBox 以及 CommandBarPopup 对象具有同样的属性和方法。
注释  若要为自定义命令栏控件编写 Visual Basic 代码,请使用 CommandBarButtonCommandBarComboBoxCommandBarPopup 对象。若要为容器应用程序中的内置控件编写代码,而该控件又不能用上述三个对象中的任意一个来表示,则可使用 CommandBarControl 对象。


CommandBarControl 的变量可取的值为:CommandBarButtonCommandBarComboBoxCommandBarPopup

本例定义哪个都可以。
发表于 2013-6-27 12:32 | 显示全部楼层    本楼为最佳答案   
CommandBarControl 对象与 CommandBarButtonCommandBarComboBox 以及 CommandBarPopup 对象具有同样的属性和方法。
注释  若要为自定义命令栏控件编写 Visual Basic 代码,请使用 CommandBarButtonCommandBarComboBoxCommandBarPopup 对象。若要为容器应用程序中的内置控件编写代码,而该控件又不能用上述三个对象中的任意一个来表示,则可使用 CommandBarControl 对象。


CommandBarControl 的变量可取的值为:CommandBarButtonCommandBarComboBoxCommandBarPopup

本例定义哪个都可以。
回复

使用道具 举报

 楼主| 发表于 2013-6-27 12:41 | 显示全部楼层
本帖最后由 sdada 于 2013-6-27 13:22 编辑
那么的帅 发表于 2013-6-27 12:32
CommandBarControl 对象与 CommandBarButton、CommandBarComboBox 以及 CommandBarPopup 对象具有同样的属性 ...


谢谢!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-3 05:33 , Processed in 0.230977 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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