Partilhar via


Customizing the Office Button Menu (aka File Menu) and No-Ribbon Custom Solutions

Even though most of the information on how to customize the Ribbon in Access 2007 is already out, there are two recurring question that I've been seeing being asked often:

How can I customize the Office Button Menu (aka File Menu)?

We allow you to show/hide any controls off of the Office Button menu, effectively customizing it fully. The way to do it is by specifying a custom ribbon, following these steps:

  1. Create a "USysRibbons" table;

  2. Create two fields: RibbonName (type 'Text') and RibbonXml (type 'Memo');

  3. Add a new record with any RibbonName you want (say, "Default");

  4. Edit the record's RibbonXml to add an XML like this:

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

    <!-- First we hide all the items displayed by default -->

    <control idMso="FileNewDatabase" visible="false"/>
    <control idMso="SourceControlCreateDatabaseFromProject" visible="false"/>
    <control idMso="FileOpenDatabase" visible="false"/>
    <control idMso="FileSave" visible="false"/>
    <control idMso="ConvertDatabaseFormat" visible="false"/>
    <control idMso="FileSaveAsMenuAccess" visible="false"/>
    <control idMso="FileManageMenu" visible="false"/>
    <control idMso="FileSendAsAttachment" visible="false"/>
    <control idMso="MenuPublish" visible="false"/>
    <control idMso="FileServerMenu" visible="false"/>
    <control idMso="FileCloseDatabase" visible="false"/>

    <!-- Now let's show a single Print Command -->
    <control idMso="FilePrintMenu" visible="true"/>  
    </officeMenu>
    </ribbon>
    </customUI>

  5. Save the table and restart the database;

  6. File Menu, Access Options, Current Database. In Toobar Options, set the "Ribbon Name" property in the "Ribbon and Toolbar Options" to the name you gave to this custom ribbon in step 3 (say, 'Default');

  7. Restart the database.

In the example above, you will notice that the File Menu only has now the Print button. Of course, you can add your own commands here.

There is however a small caveat as you probably noticed above: you will still have the "Access Options" button in the File Menu. To get rid of it, you will need to change the "Allow Full Menus" property (off of the Current Database options in the Access Options - same location as the "Ribbon Name" option above) to "No". When you set "Allow Full Menus" to "No", not only 'Access options' goes away, but most of the Ribbon tabs as well. At this point it is expected that you really want to roll your own ribbons.

Can I keep my totally custom solution with custom toolbars or will I get the Ribbon anyway?

Finally, to allay some fears I heard being spread around: if you have a completly custom solution from Access 2003 or earlier where the built-in toolbars were disabled and you had custom menubars at startup, it will be shown as you designed it when opened in Access 2007. No ribbon will show up for it.

Comments

  • Anonymous
    October 13, 2006
    What's the procedure for adding your own commands to the File menu?

  • Anonymous
    October 13, 2006
    Hi grovelli, You might want to peak at the first link I had in the article: http://msdn2.microsoft.com/en-us/library/ms406046.aspx. In a nutshell, you simply add a markup such as <button id="myButton" label="Click Me!" onAction="MyCallback"/> alongside the controls in my example above and then proceed to write a VBA or Macro callback. It's really straightforward.