Part IV: Professional Database Development
1034
15 ... Repeat Groups ...
16 </tab>
17 ... Repeat Tabs ...
18 </tabs>
19 </ribbon>
20 </customUI>
The first statement (<?xml version=“1.0” encoding=“utf-8”?>), as discussed before, is
added by Visual Web Developer, and does not affect Access ribbons. It is completely your choice
whether to keep this line or not in the USysRibbons table. Line 2 shows how to add a comment
to a ribbon’s XML code. The <!-- and --> are standard commenting tags for XML documents.
Line 3 (beginning with <customUI...) specifies an XML namespace (xmlns), an XML document
that predefines acceptable tags for the XML statements that follow. The Office namespace defines
the Office ribbon constructs (tabs, groups, controls, and so on) and enables IntelliSense in the
Visual Web Developer editor. Every ribbon defined in the RibbonXML field in USysRibbons must
start with this statement, so be sure it’s included.
Note
Beginning with Office 2010, you have another option for the CustomUI tag. The tag you see in the preceding
code applies to ribbons intended to be used in Access 2007 or 2010. If you are building a ribbon and you know
(for sure!) that it will only be used with Access 2010 (perhaps to take advantage of new features in Access
2010), you can use the following CustomerUI statement:
<customUI xmlns=“http://schemas.microsoft.com/office/2009/07/customui”>
The statement in line 4 is rather important. The startFromScratch directive notifies Access
that we are building an entire ribbon from scratch, rather than starting with the default Access rib-
bon and taking things away. Depending on your situation, the majority of your custom ribbons
may be built from scratch because the default Access ribbon knows nothing about the forms,
reports, and other objects and operations in your database. Also, the default Access ribbon con-
tains commands that may be dangerous to your application’s integrity. For instance, a user could
open a form, report, or table in design view and make changes without your being aware of it.
Removing these commands from the user interface is a first line of defense for your applications.
When startFromScratch is set to false, your custom ribbon definition is added to the
default Access ribbon to the right of the built-in tabs. Because Access only includes four tabs by
default, you may have enough room for your additional tabs without overcrowding the ribbon.
The <tabs> (line 5) and </tabs> (line 18) tags indicate the beginning and end of the tabs on
the ribbon. Ribbons are hierarchical, with tabs containing groups which contain controls. The tabs,
therefore, are the highest-level objects within a ribbon and enclose all other ribbon objects.
Line 6 defines the left-most tab on the ribbon. In this example, the tab’s name is tab1. The other
attributes for this tab are not shown, but are implied by the ellipsis (...). The ending tag for
tab1 is located on line 10.