CrazyAccessProgrammer said:
I officially give up on trying to create custom Access 2007 ribbons. I've
read a few articles that state how complicated it was to create custom
menu
bars prior to Access 2007, but if you ask me the ribbon is much more
complex
and involved.
Once you made "one" ribbon, then it a simple matter of cutting and pasting
text over and over to extend and create more buttons.
So, really, after you made "one" ribbon, then the next one is going to be
VERY little work indeed.
For example, for all reports, I built a custom ribbon as follows:
<customUI xmlns="
http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true">
<tabs>
<tab id="MyReport" label="Report">
<group idMso="GroupPrintPreviewPrintAccess" />
<group idMso="GroupPageLayoutAccess" />
<group idMso="GroupZoom" />
<group idMso="GroupPrintPreviewClosePreview" />
</tab>
</tabs>
</ribbon>
</customUI>
The above is quite simple, easy to cut and past between applications
(something
you can't do with the old menu bars).
Even more amazing is you can cut the above
from this newsgroup message! (try that with a old button!!). In other words
you can go to web sites, or take the above and cut/paste the above into your
ribbons.
Using xml as above is REALLY nice because over time, the more examples and
ribbons you make, the larger your libaraly of "easter egg" hunting becomdes.
You have more stuff to build new ribbons.
In other words you ONLY have to build one ribbon..and after that
is much a cut/paste approach.
A ribbon like the above is not really needed because ms-access has it own
ribbons for reports. However, I plan to add a button for "email report".
and, adding that button is really easy.
All I have to do to add a new button is paste in the following to the
above:
<group id="Options" label="Report Options">
<button id="button1" label="Email" onAction="=MyEmail()"/>
</group>
The above will run a public VBA function called MyEmail when clicked on.
We could then add another button to convert the report to a pdf.
<button id="button2" label="Make PDF" onAction="=MyPDF()"/>
Now, I been doing the above as I type this message, but even as I type, you
can see that I am simply cutting + pasting. Lets assume I need 3 new
buttions.
I just cut/paste 3 times and we get:
<group id="Options" label="Report Options">
<button id="button1" label="Email" onAction="=MyEmail()"/>
<button id="button2" label="Make PDF" onAction="=MyPDF()"/>
<button id="button2" label="Make PDF" onAction="=MyPDF()"/>
<button id="button2" label="Make PDF" onAction="=MyPDF()"/>
<button id="button2" label="Make PDF" onAction="=MyPDF()"/>
</group>
So, now the above last 3 lines are the same, but then I just
start editing the text in "replace" mode.
eg:
<button id="button1" label="Email" onAction="=MyEmail()"/>
<button id="button2" label="Make PDF" onAction="=MyPDF()"/>
<button id="button3" label="Button 3" onAction="=Mybt3Code()"/>
<button id="button4" label="Button 4" onAction="=Mybt4Code()"/>
<button id="button5" label="Button 5" onAction="=Mybt5Code()"/>
See how fast the cut + paste idea works. I mean, it took me VERY little time
to
write out the above button code because I was cutting + pasting to write
this message to you. In fact, creating ribbons becomes much like writing a
email
or playing in a word processor. This process is MUCH FASTER then writing
code.
I think it darn cool that I just "posted" a ribbon in this newsgroup. Hence
this "plain text" system of xml allows me to not only cut + paste, but has
allowed me to share my ribbon with you with great ease in this message!
This ribbon approach is thus a VERY expressive system in which I can easily
post and give examples for all people to see here. And the bonus is you can
then even grab (cut/paste) what I done with the above and use it in your own
ribbon.