excel中如何编写VBA代码
打开excel vba编程⼯具,在ThisWorkbook中添加如下代码:(该代码是⽤于调⽤之前写好的VBA代码所⽤,类似Java⽤到⽅法的定义)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'关闭⼯作簿前,删除新创建的⼯具条先
Dim bar_name As String
bar_name = "HRBSJ"
Application.CommandBars(bar_name).Delete
On Error GoTo Exception
Exit Sub
Exception:
End Sub
Private Sub Workbook_Open()
'打开⼯作簿时创建⼯具条
Dim bar_name As String
Dim new_bar As Office.CommandBar
bar_name = "HRBSJ"
Set new_bar = Application.CommandBars.Add(bar_name)
new_bar.Visible = True
new_bar.Position = msoBarLeft
With new_bar.Controls.Add(Type:=msoControlButton, before:=1)
.BeginGroup = True
.Caption = "⽣成建表脚本"
vba做excel窗体录入教程.
TooltipText = "⽣成建表脚本"
.Style = msoButtonCaption
.OnAction = "Create_HR_Table_Script"
End With
On Error GoTo Exception
Exit Sub
Exception:
End Sub
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论