excel表格_excel函数公式大全_execl从入门到精通
Excel工具条在《EXCEL协同平》中的应用2024-05-18 11:00:01
excel协同平台一、EXCEL控件的应用
《EXCEL协同平台》中有大量的控件在应用,如:表间公式、回写公式的手动执行、插入单元格…;但是,大量的使用控件会影响到报表页面的设计,如下图所示:
图1二、EXCEL工具条的应用
如果用EXCEL工具条取代EXCEL控件的应用,不仅会让EXCEL界面更加美观,而使用起来会更加人性化
图2三、EXCEL工具条代码设计,利用下例VBA代码,可以实现以上控件功能。
Private Sub Workbook_Open()
On Error Resume Next
Dim mynum As Integer, MYNAME As String, mycom As String
Application.CommandBars("报表管理").Delete
Application.CommandBars.Add(Name:="报表管理", _
Position:=msoBarTop).Visible = True
Call myButton("创建符件", 1, "矩形7_单击")
Call myButton("删除符件", 2, "CommandButton1_Click")
Call myButton("前期填报", 3, "矩形1_单击")
Call myButton("近期填报", 4, "矩形2_单击")
Call myButton("样单填报", 5, "矩形3_单击")
Call myButton("数据更新", 6, "矩形4_单击")
End Sub
Public Sub myButton(MYNAME As String, mynum As Integer, mycom As String)
Set newButton = Application.CommandBars("报表管理").Controls.Add( _
Type:=msoControlButton, Before:=mynum)
With newButton
.Style = msoButtonCaption
.BeginGroup = True
.Caption = MYNAME
.OnAction = mycom
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("报表管理").Delete
End Sub
标签: Excel工具