Table of contents
TOC
Collapse the table of content
Expand the table of content

Application.LoadCustomUI Method (Access)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Loads XML markup that represents a customized ribbon.

Syntax

expression. LoadCustomUI( ** CustomUIName, ** CustomUIXML )

expression An expression that returns a Application object.

Parameters

NameRequired/OptionalData TypeDescription
CustomUINameRequiredStringThe name that will be used to identify the customized ribbon.
CustomUIXMLRequiredStringThe XML markup code that defines the customized ribbon.

Remarks

To create and make the ribbon available to Access, you first create a module in the database with a procedure that calls the LoadCustomUI method, passing in the name of the ribbon and the XML customization markup. The XML markup can come from a Recordset object created from a table, from a source external to the database (such as an XML file that you must parse into a String ), or from XML markup embedded directly inside of the procedure.

You can make different ribbons available by using multiple calls to the LoadCustomUI method, passing in different XML markup, as long as the name of each ribbon and the id attribute of the tabs that make up the ribbon are unique.

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

Example

The following code example creates a Recordset from any table that contains the word "Ribbons" in its name. Then it calls the LoadCustomUI method to load the ribbons in order to make them available to the database. Finally, it closes the recordset and the reference to the Database object.

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

See also

Concepts

Application Object

© 2017 Microsoft