Application.LoadCustomUI Method

Access Developer Reference

Loads XML markup that represents a customized Ribbon.

Version Information
Version Added: Access 2007

Syntax

expression.LoadCustomUI(CustomUIName, CustomUIXML)

expression An expression that returns a Application object.

Parameters

Name Required/Optional Data Type Description
CustomUIName Required String The name that will be used to identify the customized Ribbon.
CustomUIXML Required String The 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 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)
      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