In a previous post,
Microsoft Office Pro Plus 2010, I talked about how much I enjoy developing solutions that use the new Office Fluent Ribbon UI. Along those lines, this post is the first of three upcoming posts on some specific customizations I've used in some applications recently.The general scenario is a ribbon customization to help users work with objects in an application. This first post is pretty straight-forward where we'll create a button to close the currently open object. Start with the XML for the customization:<customUI xmlns="">
<ribbon startFromScratch="false">
<tabs>
<tab id="tab1" label="Object Helpers">
<group id="grp1" label="Helpers">
<!-- close current object button -->
<button id="btnCloseObject" label="Close Current Object"
size="large"
imageMso="PrintPreviewClose"
onAction="OnCloseCurrentObject"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI> Next, create the USysRibbons table in a database to store ribbon customizations if you haven't already. You can run the following SQL statement in a new query to create the table. Since this is a data definition query,
Office 2007 Enterprise, the database will need to be enabled for this to work.CREATE TABLE USysRibbons
(
RibbonName Text(255) CONSTRAINT PrimaryKey PRIMARY KEY,
Windows 7 Serial,
RibbonXml MEMO
);In the USysRibbons table, add a new record and set the RibbonName field to "BlogSample1" and the RibbonXml field to the XML for the customization. Close and re-open the database and click the Object Helpers tab. You should have something that looks like this: You'll notice that the button in the customization calls a callback in the onAction attribute called OnCloseCurrentObject. Add the following code to a new module to implement this routine. You'll need a reference to the Microsoft Office 12.0 Object Library for this code to work.Public Sub OnCloseCurrentObject(ctl As IRibbonControl)
DoCmd.Close CurrentObjectType,
Office 2007 Pro Key, CurrentObjectName
End SubWe're using the CurrentObjectType and CurrentObjectName properties of the Application object to close the object that is currently open. To try this out,
Microsoft Office Professional Plus 2010, open a few different types of objects and click the button. <div