如在引用的前提下,定义下面的变量
Dim iBar As CommandBar
Dim iButton As CommandBarButton
Dim iCombo As CommandBarComboBox
改为不引用定义:
Dim iBar As Object
Dim iButton As Object
Dim iCombo As Object
set iBar= CreateObject("X")
set iButtonr= CreateObject("Y")
set iCombo r= CreateObject("Z")
我想知道:上面语句中的: X、Y、Z
如:下面定义一个ADO记录,就不用引用
Dim rst As As Object
Set rst = CreateObject("ADODB.Recordset")
作者: t小宝 时间: 2012-8-1 22:56
Office工具栏这些对象不需要CreateObject,像下面这样用:
Dim iBar As Object
Dim iButton As Object
Dim iCombo As Object
'引用已有的工具栏
set iBar=CommandBars("工具栏1")
'创建并引用新的工具栏
Set iBar = CommandBars.Add("工具栏2")
'创建并引用一个新的按钮
Set iButton = iBar.Controls.Add作者: 鱼儿游游 时间: 2012-8-1 22:59
哦,我试试,多谢小宝。作者: 鱼儿游游 时间: 2012-8-1 23:09
t小宝 发表于 2012-8-1 22:56
Office工具栏这些对象不需要CreateObject,像下面这样用:
Dim iBar As Object
Dim iButton A ...
没错,我试过了,在此结贴,再次多谢小宝。
Application.CommandBars(strPopupMenuName).Delete
Dim iBar As Object 'CommandBar
Dim iButton As Object 'CommandBarButton
Dim iCombo As Object 'CommandBarComboBox
Set iBar = Application.CommandBars.Add(Name:=(strPopupMenuName), Position:=msoBarPopup, Temporary:=True) 'msoBarPopup=5