怎么在Office上添加自定义的工具栏?
用Com做Office的AddIn可以添加自定义的工具栏或菜单,请问有谁有这方面的例子?
[解决办法]
教你一种方法:
1、打开visual basic 工具条,点击其中的“录制宏”按钮;
2、在工具条上右键,选择自定义
3、新建一个工具条,并拖动若干按钮到上面
4、关闭宏录制器
5、打开VBE窗口,查看其中刚刚录制的代码,你就会知道如何创建一个工具条和按钮了... ...
[解决办法]
Refer to:
http://www.codeproject.com/com/adwordaddin.asp
http://support.microsoft.com/kb/312626/zh-cn
[解决办法]
我也刚学习了一下,下面是我学习时作的一个小例子,直接addIn 就可以出来的
Private Sub Workbook_AddinInstall()
Dim cmdBar As Office.CommandBar
Dim cmdPop As Office.CommandBarPopup
Dim cmdBtn As Office.CommandBarButton
Set cmdBar = Application.CommandBars( "Worksheet Menu Bar ") ', Position:=msoBarTop)
Set cmdPop = cmdBar.Controls.Add(msoControlPopup)
cmdPop.Caption = "Exec(&E) "
Set cmdBtn = cmdPop.Controls.Add(msoControlButton)
cmdBtn.Caption = "テスト(&T) "
cmdBtn.OnAction = "ThisWorkbook.cmdBtn_OnClick "
End Sub
Private Sub Workbook_AddinUninstall()
On Error Resume Next
Application.CommandBars( "Worksheet Menu Bar ").Controls( "Exec(&E) ").Delete
End Sub
Private Sub cmdBtn_OnClick()
MsgBox ActiveWorkbook.ActiveSheet.Range( "A1 ").Text
End Sub