老师,可以将下面的代码给我讲解一下吗???? 先谢了
Private Sub Workbook_Open()
On Error Resume Next '如果出错则执行下一行代码(因为如果不存在名称为MyMenu的命令栏时会产生一个错误,用此忽略它)
Dim cmdBar As CommandBar
Dim BarCtlBtn As CommandBarButton
Application.CommandBars("MyMenu").Delete '如果已存在命令栏则删除它
With Application.CommandBars.Add("MyMenu", msoBarTop, True, False) '新建一个命令栏并以新命令栏替换活动菜单栏
Set BarCtlBtn = .Controls.Add(Type:=msoControlButton, Before:=1, Temporary:=True) '在新命令栏中第一个按钮前添加一个命令按钮
With BarCtlBtn '设置命令按钮
.Style = msoButtonCaption '设置命令按钮风格
.Caption = "[凭证查询]" '设置命令按钮标题
.OnAction = "FindPZ_Click" '设置命令按钮单击时运行的过程名称
End With
Set BarCtlBtn = .Controls.Add(Type:=msoControlButton, Before:=1, Temporary:=True) '在新命令栏中第一个按钮前添加一个命令按钮
With BarCtlBtn
.Style = msoButtonCaption
.Caption = "[凭证新增]"
.OnAction = "CreatePZ_Click"
End With
.Visible = True '设置命令栏可视
End With
End Sub
'其它具体的参数与常量可查看帮助
[此贴子已经被清风_ll于2006-6-14 12:34:45编辑过] |