會設定專案之自訂功能區使用者介面的內部 XML 值。
語法
expression。
SetCustomUI( _CustomUIXML_ )
詞 一個回傳 Project 物件的表達式。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| CustomUIXML | 必要 | 字串 | 用於修改功能區的有效 XML 資料。 |
傳回值
Nothing
註解
專案使用的二進位檔案格式,因為有 SetCustomUI 方法以程式設計方式自訂功能區。
注意事項
[!注意事項] SetCustomUI 方法會影響所有自訂項目範圍內的專案。 例如,若企業全域專案或本地 Global.mpt 專案已有自訂,若要進行額外自訂,必須在 CustomUIXML 參數中包含現有的 XML 定義。
CustomUIXML 值必須是 Microsoft Office 自訂功能區內容的有效 XML。 XML 值的開頭必須 mso:customUI 元素,後面接著 mso: ribbon 元素。 如果 mso: ribbon 元素是空的 SetCustomUI 會移除功能區自訂。
有好幾篇文章討論如何在 Microsoft Office 應用程式中自訂 Fluent 使用者介面的色帶。 欲了解更多資訊,請參閱 Office Fluent獎帶概述。
範例
下列範例會將 新的索引標籤新增至左邊的功能區中的 [ 檢視] 索引標籤。 新的索引標籤包含名為 新群組的群組。 在群組] 按鈕名為 Test 按鈕並使用名為 GetExternalDataFromText 內建的 Microsoft Office 圖示文件庫中的圖像。
Sub AddCustomUI()
Dim customUiXml As String
customUiXml = "<mso:customUI xmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">" _
& "<mso:ribbon><mso:tabs><mso:tab id=""myTab"" label=""New Tab"" " _
& "insertBeforeQ=""mso:TabView"">" _
& "<mso:group id=""group1"" label=""New Group"">" _
& "<mso:button id=""button1"" label=""Test Button"" size=""large"" " _
& "imageMso=""GetExternalDataFromText"" />" _
& "</mso:group></mso:tab></mso:tabs></mso:ribbon></mso:customUI>"
ActiveProject.SetCustomUI (customUiXml)
End Sub
下列範例會移除所有的功能區自訂,因為 mso: ribbon 元素是空的。
Sub RemoveCustomUI()
Dim customUiXml As String
customUiXml = "<mso:customUI xmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">" _
& "<mso:ribbon></mso:ribbon></mso:customUI>"
ActiveProject.SetCustomUI (customUiXml)
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。