LoadCustomUI Method
This documentation is archived and is not being maintained.

Application.LoadCustomUI Method

Office 2007
Loads XML markup that represents a customized Ribbon.

Version Information
 Version Added:  Access 2007


expression.LoadCustomUI(CustomUIName, CustomUIXML)

expression   An expression that returns a Application object.


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


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


The following 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.

Visual Basic for Applications
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)

      While Not rs.EOF
            Application.LoadCustomUI rs("RibbonName").Value, rs("RibbonXml").Value


      Set rs = Nothing
   End If
Next i

Set db = Nothing
End Function

© 2016 Microsoft