|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 wpxxsyzx 于 2013-6-22 16:56 编辑
没有写详细的制作过程需要对功能区及xml文件有一定了解
1、隐藏指定的内置或自定义选项卡
xml文件的代码:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
- <ribbon>
- <tabs>
<tab idMso="TabHome" getVisible="GetVisible" />
<tab idMso="TabInsert" getVisible="GetVisible" />
- <tab id="wpTab1" label="WP1" getVisible="GetVisible">
- <group id="wp1Group" label="我的工具1">
<button id="wp1Button1" label="工具" size="large" imageMso="AnimationAudio" />
</group>
</tab>
- <tab id="wpTab2" label="WP2" getVisible="GetVisible">
- <group id="wp2Group" label="我的工具2">
<button id="wp2Button1" label="工具" size="large" imageMso="FilePackageForCD" />
</group>
</tab>
- <tab id="HideTab" label="显示隐藏选项卡" insertBeforeMso="TabHome">
- <group id="HideGroup1" label="显示隐藏内置选项卡">
<button id="ShowButton1" label="显示开始选项卡" size="large" imageMso="AcceptInvitation" />
<button id="ShowButton2" label="显示插入选项卡" size="large" imageMso="AcceptInvitation" />
<separator id="MySeparator1" />
<button id="HideButton1" label="隐藏开始选项卡" size="large" imageMso="DeclineInvitation" />
<button id="HideButton2" label="隐藏插入选项卡" size="large" imageMso="DeclineInvitation" />
</group>
- <group id="HideGroup2" label="显示隐藏自定义选项卡">
<button id="ShowButton3" label="显示WP1选项卡" size="large" imageMso="AcceptInvitation" />
<button id="ShowButton4" label="显示WP2选项卡" size="large" imageMso="AcceptInvitation" />
<separator id="MySeparator2" />
<button id="HideButton3" label="隐藏WP1选项卡" size="large" imageMso="DeclineInvitation" />
<button id="HideButton4" label="隐藏WP2选项卡" size="large" imageMso="DeclineInvitation" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
vba代码:
Public Rib As IRibbonUI
Public bHome As Boolean
Public bInsert As Boolean
Public bWP1 As Boolean
Public bWP2 As Boolean
Sub RibbonOnLoad(Ribbon As IRibbonUI)
bHome = True
bInsert = True
bWP1 = True
bWP2 = True
Set Rib = Ribbon
End Sub
Private Sub GetVisible(Control As IRibbonControl, ByRef Visible)
Select Case Control.ID
Case "TabHome"
Visible = bHome
Case "TabInsert"
Visible = bInsert
Case "wpTab1"
Visible = bWP1
Case "wpTab2"
Visible = bWP2
End Select
End Sub
Sub Show(ByVal Control As IRibbonControl)
Select Case Control.ID
Case "ShowButton1"
bHome = True
Case "ShowButton2"
bInsert = True
Case "ShowButton3"
bWP1 = True
Case "ShowButton4"
bWP2 = True
End Select
Rib.Invalidate
End Sub
Sub Hide(ByVal Control As IRibbonControl)
Select Case Control.ID
Case "HideButton1"
bHome = False
Case "HideButton2"
bInsert = False
Case "HideButton3"
bWP1 = False
Case "HideButton4"
bWP2 = False
End Select
Rib.Invalidate
End Sub
Sub OnAction(Control As IRibbonControl)
MsgBox "你点击了我!"
End Sub
Public Sub MarcoShow()
bHome = True
Rib.Invalidate
End Sub
Public Sub MarcoHide()
bHome = False
Rib.Invalidate
End Sub
隐藏选项卡中指定的组合隐藏选项卡大同小异
|
评分
-
6
查看全部评分
-
|