CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT...

24
Relational Database Design CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS This short tutorial will show you how to create your own ribbon in Access. Adding a ribbon can be done in various ways. The steps described in this tutorial use the UsusRibbons functionality. Easy to create and easy to maintain. You need Microsoft Access to perform the steps described in the tutorial. The steps have been verified in Microsoft Access 2007, 2010 and 2013. Schemas used in the XML The schemas used in the tutorial refer to the 2009/07 schema. If you use Office 2007 then you should use the 2006/01 schema. Don’t worry where applicable it will be pointed out to you during the steps you take.

Transcript of CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT...

Page 1: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Relational Database Design

CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS

This short tutorial will show you how to create your own ribbon in Access. Adding a ribbon

can be done in various ways. The steps described in this tutorial use the UsusRibbons

functionality. Easy to create and easy to maintain.

You need Microsoft Access to perform the steps described in the tutorial. The steps have

been verified in Microsoft Access 2007, 2010 and 2013.

Schemas used in the XML

The schemas used in the tutorial refer to the 2009/07 schema. If you use Office 2007 then

you should use the 2006/01 schema. Don’t worry where applicable it will be pointed out to

you during the steps you take.

Page 2: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Enter XML The Ribbon was first introduced in Microsoft Office 2007. It is part of the so called Fluent

Interface ideology of Microsoft. This change had a great impact on the way we work with our

Office applications today. No exception was made for Microsoft Access and so users of this

application also had to dive into working with the ribbon. Besides that the old database

windows was also taken away from us. Some sort of Navigation Pane became the standard to

work with. For years developers could create their own menubars. That was about to change.

Of course the menubars would still work but you had to search for them in a Ribbon tab

calles Add ins. From now on we had to get cracking at XML. This section will show you how

to create your own ribbon for your application.

Extensible Markup Language (XML) is a markup language that defines a set of rules for

encoding documents in a format which is both human-readable and machine-readable. It is

defined by the W3C's XML 1.0 Specification[2] and by several other related specifications,[3]

all of which are free open standards.[4]

The design goals of XML emphasize simplicity, generality and usability across the Internet.[5]

It is a textual data format with strong support via Unicode for different human languages.

Although the design of XML focuses on documents, it is widely used for the representation of

arbitrary data structures[6] such as those used in web services.

Several schema systems exist to aid in the definition of XML-based languages, while many

application programming interfaces (APIs) have been developed to aid the processing of XML

data.

http://en.wikipedia.org/w/index.php?title=XML&redirect=no

Page 3: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

USysRibbons table It is possible to create a ribbon in various ways. The first option is to use the System table in

which the info of the ribbon is defined and stored. De second option is to build a ribbon

completely from 'VBA-code'. This section will focus on option one where we use the USys

table technique. This can be done in Access 2007, 2010 and 2013 ....

To create your own ribbons in Access you need to implement certain mandatory elements in

your database. The first object that is mandatory is the USysRibbons table. Follow the next

steps to create this table. NOTE: naming conventions and datatypes should be exactly the

same for a working ribbon!

1. Create a new empty (client) database and give it a appropriate name;

2. Create a new empty table and make sure it is in design mode. If you get a table in

datasheet mode change it back to design mode. In that case you have to provide a

name for it. This table should be called USysRibbons

3. Create the following fiels in the table

Fieldname Datatype Description (optional)

ID Autonumber Keyfield

RibbonName Text 255 characters

RibbonXML Memo

Access 2013 does not have the datatype Memo and Text. Instead choose Short

Text and Long Text that will do the trick!

4. Save the table (and if not done so) call it: USysRibbons

5. Because the table has a prefix Usys Access will 'see' this table as a system table. By

default the Access settings are not to show system tables. The average user will not see

this table. For now we do need to see the table so let's make them visible.

Page 4: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

6. Show system tables: (rightclick on mouse)

Page 5: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

XML Default Template

Page 6: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

RibbonXML Basics

In the UsysRibbons table we created earlier we are going to add records with the values we

need for our ribbon. Every record in this table can be a seperate ribbon in Access. We will

start of with the creation of one ribbon just to get the basics right first.

For the first steps we are going to use good old Notepad. Of course you will find various XML

editors on the web but how conveniant is it that you actually don't have to dowload

something first to get started! So for now open Notepad and take a look at the XML lines

below. Those are the lines we are going to use. Make sure you typ the lines instead of just

copying them. By typing them yourself you will get a much better feeling of what you are

accomplishing. However you are free to copy it if you want to.

Where applicable i will tell you about the differences between the different versions of Access.

As you might have noticed the famous Office Button has disappeared in the 2010 and beyond

versions of Access. From 2010 and on we have to deal with the Backstage option.

Every first line for constucting a ribbon starts with the same components they are:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">

This line sets a reference to the Office 2007 version !!

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> This line sets a reference to the Office 2010 (and later) versions

Next we need some more mandatory elements that need to be present.

<ribbon startFromScratch="true"> true refers to creating a new clean ribbon with no other ribbons to be shown. Only your ribbon

will show up. Set this to false and all default ribbons will show up as well. Your ribbon will be added last by default. o Hides all build in tabs including the [Add ins] tab. o The Office button only shows the following options (2007):

New, Open, Save as, Access Options en Exit Access

<tabs>

This is where all information will be added to create your own ribbon. You will see this in the next steps.

At the end all 'Open' tags should get 'Close' tags as well. That makes it easy to create a template for

this!

</tabs> </ribbon> </customUI>

The complete XML could look somthing like this:

Page 7: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon startFromScratch="true">

<tabs>

-This is where your following elements will be written - </tabs>

</ribbon> </customUI>

Important: XML is case sensitive! so be sure to check the syntax for capitalization

where needed. I will point that out where needed!

Equally important: although it looks like a link to click on this link is just a reference

link and will not provide you with any additional information about creating ribbons.

It's a pointer for XML to check the XML. See image below

Exercise: Create a tab

Page 8: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

In this exercise we are going to create a ribbon with three tabs. Next we will show what it

takes to actually show our ribbon when we start up our database. The next steps will be

to expand the functionality in our ribbon tabs.

First things first:

Open the database we created earlier, the one where you added the USysRibbon

table.

Open the table USysRibbons in datasheet mode because we are going to add a

record. Typ (or copy) the following XML snippet in the field [RibbonXML]. The autonumber

field will set a number by deafult so we won't have to think about that. In the

RibbonName field typ MyRibbon <customUI xmlns="http://schemas.microsoft.com/office/2007/09/customui">

<ribbon startFromScratch="true">

<tabs> <tab id="MyTab1" label="My Tab 1"/>

<tab id="MyTab2" label="My Tab 2"/> <tab id="MyTab3" label="My Tab 3"/>

</tabs> </ribbon>

</customUI>

Your table entry should look something like this:

After adjustments it can look like this (this is not mandatory!) See remarks at

the end of the section.

Page 9: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

You can now close the table. To activate our own ribbon we have to close the

database first. Yes you do have to close the database once after creating your

records in the USysRibbon table. But wait. Access doesn't know we have created our own ribbon yet so we have to

set some settings. You do so by clicking the File - Options. In the dialog that pops

up click the Current Database menuoption. Now look for the Ribbon and Toolbar

Options an set the combobox to MyRibbon.

Close the database again. Now start up your database once more and see if you have

created the magic we were looking for.

Page 10: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Result if your XML is correct

Very Important: when typing in the XML (preferred to copying) just typ everyting without

hitting the ENTER key because that will cause Access to go to the next record. Instead just

typ everything in one line. When finished you can make the adjustments.

Neatly readable: If you want to have the same output as shown in the image above then do

the following steps. After each section where you want an Enter just hit Ctrl+Enter to go to a

new line in the record. This will give you the same layout as shown in the image above.

Copying and pasting will not give you the same layout. Although optically it looks the same

you will have major 'spaces' which need to be removed first!

Exploring the Ribbon

Page 11: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Element in the Ribbon

In the last exercise we scratched a little XML in creating our own ribbon. These were the first

steps. Before we continu our journey i think it would be a good idea to explore the ribbon

just a bit more. How is this ribbon setup, which elements can we identify. These are some

questions we need to get answers to before we can continu. After exploring the ribbon we

are ready to take our next steps. Try to identofy the various elements. These are the ones we

are going to add in our ribbon XML.

In the image above it shows that a ribbon consists of quit a lot of elements. Not only Access

but also in the other Office Apps. That's important to know because once you have written

some XML for Access adding a ribbon to Excel or Word is childsplay. All elements have their

own purpose. If you want to create your own ribbon in Access you should know how these

are created in the XML. Let's have a closer look at the various elements.

1. Backstage (Office Button in 2007): A story of its own. This is the place where you'll find

the options for setting application variables. In the XML it's important to know which

version you are creating a ribbon for. If you want to 'edit' the backstage tab you'll have

to set the namespace to the 2010 version as described earlier.

2. The Quick Access Toolbar. Another specific element in the ribbon. The place for the

'regular' user to store options to modify his own mini ribbon. If you are building a

database you might want to 'hide' this option.

3. Tab: If we are talking bout a ribbon we are actually talking about a tab. A ribbon exists

of various tabs which have their own optiosn to choose from. An application can have

multiple tabs and multiple ribbons to choose from. During the exercise we are creating

new tabs with our own options.

4. Button: In a tab we can place various elements. One of the is the button element. A

button consists of a button and a button label. You can adjust the size of a button in

your XML. Clicking on a button can trigger a macro of default functionality.

Page 12: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

5. Contectual tab: Contextual tabs appear when a certain object is active. In the image

above you see the contextcual tab "Design" active. Contextual tabs disappear once that

specific object is closed.

6. Group: Buttons that logiaclly belong together are being arranged in a logical group.

This is not a rule but is sure makes the tab logically build. Groups are being seperated

by Seperators (these are the vertical gray lines). A group has its own groupname to

identify the activity it is based on.

Expanding the XML code

After reading this we now know what elements are used in a ribbon. Besides our own

functionality it is also possible to use the build in functionality of the application. For example

take the Search functionality. This is default functionality and can be added as such. No code

needed! In our next exercises we are going to expand our ribbon. Different elements mean

adjusting the existing XML code. You will notice dat XML conatins a lot of logic. Follow the

rules and you will be making your own ribbons in a flash! First we are going to add the

various elements in our ribbon. After that we are going to add 'actions' to our added

elements in our ribbon.

In this exercise we will add a button to our ribbon. To add a button to the ribbon we will have

to extnd our XML from our ribbon. We will add more options to our ribbon but we start of

with a button. Om een knop toe te voegen aan het lint zullen we de bijbehorende XML van

dat lint moeten aanvullen. We zullen het lint steeds verder uitbreiden maar beginnen dus met

de knop.

Follow XML rules

To create a ribbon for our Access database (and also for other Office apps) we have to follow

some rules to make a ribbon succesfully. XML code case sensitive. This means that

capitalizing a character that should not be capitalized will cause an error. So be careful when

writing XML code. Cut, paste, copy it can all be done. During these actions the most common

mistakes are made. You are warned :-)

For this exercise we use our earlier made XML code.

Take a look at the XML below. Notice anything? What you should notice is that every tab will

get its own ID. That's one of the rules you have to follow. This is also one of the pitfalls to

consider. Why? Because many objects look alike and you are tempted to copy and past that

specific code. In many cases peple forget to change the element id's when copy pasting and

that's where the ribbon will error out. So remember if you do copy and paste xml code don't

forget to change the id's and make them unique. That is mandatory!

Page 13: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="true">

<tabs>

<tab id="MyTab1" label="My Tab 1"/>

<button id="MyButton1" size="large" label="Print Large" imageMso="PrintDialogAccess"/>

<tab id="MyTab2" label="My Tab 2"/> <tab id="MyTab3" label="My Tab 3"/>

</tabs>

</ribbon> </customUI>

Add the line which has a border around it to your XML and save the record. Close and reopen

the database. What's the result?

Explanation: When you start creating a ribbon you will not notice the order of elements. If

you think back to the part where we explored the ribbon you can see that there is a specific

order to follow. In the above XML one important element is missing and that's the element

"Group". It makes no difference how many objects you place inside that group you have to

make one group at minimum. Take a look at any ribbon and you will see that all elements

are placed in a group even if it contains only one button. So we will the XML once more to

get the desired result.

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">

<ribbon startFromScratch="true"> <tabs>

<tab id="MyTab1" label="My Tab 1">

<group id="MyGroup1" label="My Group"> <button id="MijnButton1" size="large" label="Print Large"

imageMso="PrintDialogAccess"/> </group>

</tab> <tab id="MyTab2" label="My Tab 2"/>

<tab id="MyTab3" label="My Tab 3"/>

</tabs> </ribbon>

</customUI>

Adjust the XML to the XML as shown above. Be careful and take a real close look at what has

changed! Close and reopen the database. What's the result?

Page 14: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Order in XML

After completing the exercise we have to conclude that there is one importance we have to

consider: the order! We need to place opening and closing tags where expected. So to

summarize: the order of XML elements are important. You can not add a button without

adding a group! So what do we need to create a ribbon? We need a ribbon, at least one tab,

at least one group and at least one button.

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">

<ribbon startFromScratch="true"> <tabs>

<tab id="MyTab1" label="My Tab 1"/>

<group id="MyGroup1" label="My Group"> <button id="MyButton1" size="large" label="Print large"

imageMso="PrintDialogAccess"/> </group>

</tab>

</tabs> </ribbon>

</customUI>

Every tag has a closing tag. The order of elements is: customUI, ribbon, tabs, tab, group,

button

Exercise: The challenge

Page 15: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

The next exercise is a challenge! With what you have learned so far try to recreate the

ribbon as shown below. You can use the existing XML code.

For the images you need the following image Mso's PrintDialogAccess FindDialog Filter UserRolesManage Export

What do you notice when you are writing your XML?

Did you get it right the very first time? If you did not what was the cause of not succeeding?

Instead of choosing the obvious choice for a small icon i would pick "small" instead of

"large". You will notice that XML doesn't understand the option "small". You will have to use

"normal" for a small icon!

Thus far we have created a ribbon, added a tab and a group and button. We can press the

button as long as we want but nothing will happen. So eventually this should lead to an

action being performed. To make this happen we have to take some action. First we have to

adjust the existing XML and secondly we have to write a macro in Access that performs the

actual action. We will alter our XML to create the option to perform the action. Next we will

add a simple macro in Access that we can trigger when the appropriate button is pressed.

The XML has to be extended with an additional attribute onAction. Behind the onAction we

write the name of the macro which we use in Access to perform the action. We will use our

earlier created XML and extend this with the onAction.

Page 16: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="true">

<tabs>

<tab id="MyTab1" label="My Tab 1"/> <group id="MyGroup1" label="My Group">

<button id="MyButton1" size="large" label="Print Large" imageMso="PrintDialogAccess"

onAction="MyCallBackOnAction"/>

</group> </tab>

</tabs> </ribbon>

</customUI>

Write our VBA Subroutine

We have extended our XML with the needed attribute to call our action. We call the action

"MyCallBackOnAction" to perform our task. Access will try to do so but it doesn't find the

calling macro. So we have to write this macro.

Open Access and open your database where you are programming the ribbon in. Now open

the Visual Basic Editor window by pressing ALT-F11. Now choose Insert -> Module.

Next we will add the follwing subroutine. So either typ it or past code below in your screen:

Public Sub MyCallBackOnAction() MsgBox "Hello World", vbExclamation End Sub

Page 17: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Click Save on the menubar to save the module. Give it a meaningful name. Close the

database and reopen it again. Now press the button [Print Large]. What's the result?

A reference to the calling control

The subroutine we wrote doesn't trigger any action. What could be the issue that our macro

is not working or might there be something wrong with our XML? We know that creating a

ribbon via XML is bound to strict rules. Let me explain what happens. In the ribbon we have

'written' so far there are five buttons defined. How is Access to know which button has been

pressed? Exactly, Access should receive some sort of identifier to determin which button is

pressed.

When one of the buttons is pressed the identifier is passed as well. We have to pass this

identifier as well in our subroutine so Access knows which button was pressed. We achieve

this by adding a argument to our subroutine in which we tell Access which control has been

banging on our door. Take a look at the minor adjustments i made to the subroutine.

Public Sub MyCallBackOnAction(control As IRibbonControl) MsgBox "Hello World", vbExclamation End Sub

The argument (shown in blue) tells Access which button is pressed in the ribbon. Question;

what would be the value of the [control] that is passed to the Access subroutine? If we alter

the subroutine with the latest changes and restart the database again what will be the result

when we click the button?

Library References

You will see that you'll have one last step to take before everything works as expected. In our

subroutine we reference to the class IRibbonControl. This library is of by default in Access.

This will resolve into an error stating the macro can not be executed. So activate this library

by taking these final steps:

Go to the VBE (ALT+F11)

Page 18: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

In the menubar click on Tools - References (below)

In the next dialog look for the appropriate library reference and click on the checkbox in

front of it

That's it that's all there is to it!

Now if you close the database and reopen it you can click the button. If all went well you

should see a messagebox appear!

Page 19: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

The correct library references.

NOTE: for Office 2007 the reference is Microsoft Office 12.0 Object library... for 2010 it

is Microsoft Office 14.0

Anyone know what happened to 13.0?

Use of internal Groups

Page 20: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

Maybe you would like to use some default functionality that comes with the build in ribbons.

This is possible by making use of the so called internal groups in your XML code. One option

every user loves is the option to search and find stuff. This functionality is build in by default

in the regular Home tab. So it would be something we could easily add to our own ribbon

right?

Use of an internal Group

Let's see if we can add this functionality to our own XML code. To begin we open the

database and then we open the USysRibbons table in datasheet mode (just doubleclick it in

the navigation pane). We go to the RibbonXML field and resize it a bit for readability so we

can easily add our additions.

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">

<ribbon startFromScratch="true">

<tabs>

<tab id="MyTab1" label="My Tab 1">

<group idMso="GroupFindAccess"/>

<group id="MyGroup1" label="My Group">

<button id="MyButton1" size="large" label="Print Large" imageMso="PrintDialogAccess"/>

</group> </tab>

</tabs>

</ribbon> </customUI>

In the XML code (as shown above) we have added one line of extra XML.

<group idMso="GroupFindAccess"/> this line will take care of adding the functionality we

are looking for. Search and Find in Access. This group contains the regular functionality that

the build in tab also offers. If at all possible try adding as much buildin functionality as

possible. Your end users will thank you for it!

Page 21: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

NOTE: the images were taken from Access 2013. If by any chance your ribbon doesn't work try compacting and repairing your database. Just click the file button an you'll see a big button there!

My XML code in the database:

In this exercise we are going to add build in functionality to our second tab in our ribbon. In

the previous section you read how to add this functionality to your own tab. Take a look at

the image below and try to recreate this in your own database.

Page 22: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

One thing you have to know is the Group names to use when adding this functionality to

your XML. In the example the following default groups are used:

1. GroupPrintPreviewPrintAccess

2. GroupPageLayoutAccess

3. GroupZoom

4. GroupPrintPreviewClosePreview

I've created a report in the database. Nothing fancy just added it with the wizard. This doesn't

have to be a fancy report just one we can use to activate our ribbon. Open the report in print

preview and see the ribbon getting activated!

My XML code in the database:

In previous versions of Access we had those nice menubars that could collapse. Of course you can do this in your ribbon as well. It won't surprise you that you have to expand your XML code to achieve this. So for now this will be our final exercise. We will use our database we have created and in our third tab we will add a dropdown option with the various options to choose from.

Page 23: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

We start of by opening the USysRibbons table and add lines to our RibbonName field: <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">

<ribbon startFromScratch="true"> <tabs>

<tab id="MyTab1" label="My Tab 1"> <group id="MyGroup" label="My Group">

<button id="MyButton1" size="large" label="Print Large" imageMso="PrintDialogAccess" onAction="MyCallBackOnAction"/> <button id="MyButton2" size="large" label="Search Large" imageMso="FindDialog" onAction="MyCallBackOnAction"/> <button id="MyButton3" size="large" label="Filter Large" imageMso="Filter" /> <button id="MyButton4" size="normal" label="User" imageMso="UserRolesManage" /> <button id="MyButton5" size="large" label="Export" imageMso="Export" />

</group> </tab> <tab id="MyTab2" label="My Tab 2">

<group idMso="GroupPrintPreviewPrintAccess" /> <group idMso="GroupPageLayoutAccess" /> <group idMso="GroupZoom" /> <group idMso="GroupPrintPreviewClosePreview" />

</tab> <tab id="MyTab3" label="My Tab 3">

<group id="grpReports" label="Reports"> <button id="cdmRpt1" label="Added Work" size="normal" imageMso="CreateReport" /> <button id="cdmRpt2" label="Open Invoices" size="normal" imageMso="CreateReport"/>

<menu id="mnuProjectsReports" label="More reports…" imageMso="CreateReport" itemSize="normal">

<button id="cdmRpt3" label="Open Orders" imageMso="CreateReport"/> <button id="cdmRpt4" label="Open Instructions" imageMso="CreateReport"/> <button id="cdmRpt5" label="Show Locations" imageMso="CreateReport"/> <button id="cdmRpt6" label="Show Employees" imageMso="CreateReport"/> <button id="cdmRpt7" label="Show Credits" imageMso="CreateReport"/> <button id="cdmRpt8" label="Open 3 months" imageMso="CreateReport"/>

Page 24: CREATE YOUR OWN RIBBON IN MICROSOFT ACCESS · PDF fileCREATE YOUR OWN RIBBON IN MICROSOFT ACCESS ... The steps described in this tutorial use the UsusRibbons ... completely from 'VBA-code'

<button id="cdmRpt9" label="Open last week" imageMso="CreateReport"/> <button id="cdmRpt10" label="Open per location" imageMso="CreateReport"/> <button id="cdmRpt11" label="Satisfactory Survey" imageMso="CreateReport"/> <button id="cdmRpt12" label="Closed projects" imageMso="CreateReport"/> <button id="cdmRpt13" label="Show Toolbox" imageMso="CreateReport"/> <button id="cdmRpt14" label="Show Recall" imageMso="CreateReport"/>

</menu>

</group> </tab>

</tabs> </ribbon>

</customUI>

Final result…..

NOTE: some xml has been word-wrapped. The imageMso should be directly after the

preceding lines of XML so don’t press enter in your code.