Access VBA Macro Programming

(Joao Candeias) #1
Save your form and then click the Form view icon in the Views group of the ribbon. You will
now see that your form opens with only the file (backstage) option visible. The Navigation pane
is still visible but techniques to remove this as well are described in Chapter 24.
Close your form and the default ribbon and the menu will reappear. You can make your
custom ribbon the default ribbon for your Access application by clicking the Windows Start
button (in the top-left corner of the window) and then clicking Access Options. Click Current
Database in the left-hand pane of the pop-up window and scroll down to the Ribbon and
Toolbar Options section. In the Ribbon Name drop-down, select your custom ribbon and
click OK. Close the database and then reopen it and your custom ribbon will appear.
Working through the preceding process, you will have noticed that there are a few problem
areas in this method of building your own ribbon. First, how do you get error messages if the
ribbon XML is incorrect?
You can show errors by clicking file in the Access menu, clicking Options in the left-hand
pane, and selecting Client Settings from the left-hand pane of the pop-up window. Scroll
down to the General section and check the box for Show Add-in User Interface Errors. Click
OK. Once your ribbon XML is loaded, any errors will now be shown.
A further problem is working with the XML in the RibbonXML field of the table. This is
a bit like trying to look through a keyhole at what will become a large piece of XML. One
solution is to design a new form bound to the USysRibbons table and to put a large text box
on it to allow editing of the RibbonXML field.
However, there is also a tool to help you, called the Microsoft Office 2007 Custom UI
Editor, which can be downloaded for free from http://www.openxmldeveloper.org/articles/
CustomUIeditor.aspx.
You only need to download it, agree to Microsoft’s terms and conditions, and then run
the installer. If you work in a corporate environment, you will need permission from your
employer to download this. (I have worked in companies where you can be dismissed for
downloading applications from the Internet.)
Strictly speaking, this tool is really for use with XML files from Excel or Word, but you
can develop your XML code in here, using all the error checking and call back facilities and
then copy and paste the XML into the RibbonXML field of your USysRibbons table.
By the way, there is no limit to the number of custom ribbons you can create within the
USysRibbons table.

Using the Custom UI Editor


After you have installed the Custom UI Editor, click the Windows Start button and click All
Programs. You will see a new program called Custom UI Editor for Microsoft Office. Click
this and you will see the opening screen as shown in Figure 11-2.
The interface is very simple and allows you to edit the ribbon on all Office 2010 documents.
However, we are only interested in Access.
An advantage of the editor is that it has built-in error checking for your XML. Simply
click the red tick icon in the editor toolbar (four icons from the left) and your XML will be
validated, with error messages displayed as to where the problems are.

132 Microsoft Access 2010 VBA Macro Programming

Free download pdf