Access) (Application.LoadCustomUI 方法

載入代表自訂功能區的 XML 標記。

語法

運算式LoadCustomUI (CustomUINameCustomUIXML)

表達 會傳回 Application 物件的運算式。

參數

名稱 必要/選用 資料類型 描述
CustomUIName 必要 字串 要用於識別自訂功能區的名稱。
CustomUIXML 必要 字串 會定義自訂功能區的 XML 標記代碼。

註解

若要建立並讓功能區可供存取,您先建立一個模組呼叫 LoadCustomUI 方法,傳遞功能區和 XML 自訂標記的名稱中的程序與資料庫中。 XML 標記可能來自利用資料表建立的 Recordset 物件、來自資料庫外部的來源 (例如必須剖析為 String 的 XML 檔案),或是來自直接內嵌在程序中的 XML 標記。

您可以讓不同的功能區可供使用多個通話 LoadCustomUI 方法,將傳遞給在不同的 XML 標記,只要是唯一的每一個功能區的名稱及構成功能區索引標籤的 id 屬性。

After the procedure is complete, you then create an AutoExec macro that calls the procedure by using the RunCode action. That way, when the application is started, the LoadCustomUI method is automatically executed and all of the custom ribbons are made available to the application.

範例

下列程式碼範例會建立 Recordset 從任何表格包含單字"區 」 在其名稱。 然後,它會呼叫 LoadCustomUI 方法來載入功能區,使其可供資料庫使用。 最後,它會關閉 recordset 與 資料庫 物件的參照。

Function LoadRibbons() 
Dim i As Integer 
Dim db As DAO.Database 
Set db = Application.CurrentDb 
 
For i = 0 To (db.TableDefs.Count - 1) 
 If (InStr(1, db.TableDefs(i).Name, "Ribbons")) Then 
 Dim rs As DAO.Recordset 
 Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name) 
 rs.MoveFirst 
 
 While Not rs.EOF 
 Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value 
 
 rs.MoveNext 
 Wend 
 
 rs.Close 
 Set rs = Nothing 
 End If 
Next i 
 
db.Close 
Set db = Nothing 
End Function

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應