RibbonName: HideData
RibbonXml:
<customUI xmlns="https://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
<tabs>
<tab idMso="TabCreate" visible="false" />
<tab id="dbCustomTab" label="A Custom Tab" visible="true">
<group id="dbCustomGroup" label="A Custom Group">
<control idMso="Paste" label="Built-in Paste" enabled="true"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
指定表單/報表專用功能區:設計模式開啟物件,設定其 RibbonName 屬性為 USysRibbons 中的名稱。
適用於執行時期依條件產生功能區(如列出所有表單的開啟按鈕)。
RibbonLoader。CreateFormButtons() 函數動態組裝 XML:Function CreateFormButtons()
Dim xml As String, template As String, formContent As String
Dim frm As AccessObject
xml = "<customUI xmlns=""https://schemas.microsoft.com/office/2006/01/customui"">" & vbCrLf & _
" <ribbon startFromScratch=""false"">" & vbCrLf & _
" <tabs>" & vbCrLf & _
" <tab id=""DemoTab"" label=""LoadCustomUI Demo"">" & vbCrLf & _
" <group id=""loadFormsGroup"" label=""Load Forms"">" & vbCrLf & _
" {0}" & vbCrLf & _
" </group>" & vbCrLf & _
" </tab>" & vbCrLf & _
" </tabs>" & vbCrLf & _
" </ribbon>" & vbCrLf & _
"</customUI>"
template = "<button id=""load{0}Button"" label=""Load {0}"" onAction=""HandleOnAction"" tag=""{0}""/>" & vbCrLf
For Each frm In CurrentProject.AllForms
formContent = formContent & Replace(template, "{0}", frm.Name)
Next
xml = Replace(xml, "{0}", formContent)
Debug.Print xml
On Error Resume Next
Application.LoadCustomUI "FormNames", xml
End Function
HandleOnAction 回呼函數。動態載入讓功能區隨應用程式狀態彈性變化,是進階 Access 開發的關鍵技術。