FAQ (Access 2007/2010/2013)
|
Only Access 2010 / 2013 - FAQ |
Open the dialog "Customize the Quick Access Toolbar".
In the dialog box select a section in "Choose commands from:" and go with the mouse over the required command. The tooltip will show the underlying command and in parentheses the appropriate idMSO for the command and the assigned icon.
In Sample DB 3 you can find all possible "Icons" on tab "IconGallerie" in the group "Office Icons". By click on the desired icon a form will open and you can copy "imageMso".
In the link list you will also find a link to the ControlID list. In there you will find all idMso of Office 2007.
#CMSimple hide#
Application.CommandBars.ExecuteMso ("idMSO")
Sample: Close current database ("Office Button" / "Close Database")
Application.CommandBars.ExecuteMso ("FileCloseDatabase")
#CMSimple hide#
For Access 2007: "Office Button" / "Access Options" / "Advanced" / "General" / "Show add-in user interface errors" needs to be checked.
For Access 2010 and Access 2013 use: "File" / "Options" / "Client Settings" / "General" / "Show add-in user interface errors"
With this option switched on all errors generated by Ribbon XML will be shown.
#CMSimple hide#
User-defined Ribbons require a reference to "Microsoft Office 12.0 Object Library" for Office 2007,
for Office 2010 use "Microsoft Office 14.0 Object Library",
for Office 2013 use "Microsoft Office 15.0 Object Library".
from Version Office 2016 use "Microsoft Office 16.0 Object Library".
To set the reference open any module (to start the Visual Basic Editor), menu "Tools" / "References...", and place a check on "Microsoft Office 1x.0 Object Library". Confirm the references dialog with "OK".
#CMSimple hide#
You can remove all entries from the Office menu (Instructions), however, the Office Button itself cannot be removed.
#CMSimple hide#
Open the database while holding the [Shift]-button.
If you do not want any ribbon to be loaded when opening your database, go to "Office Button" / "Access-Options" / "Current Database" / "Ribbon and Toolbar Options" / "Ribbon Name:" and remove the selection.
#CMSimple hide#
Remove the tick from:
A2003: "Tools" / "Startup" / "Allow Build-in Toolbars"
Select your menubar from the drop-down "Menu Bar"
A2007: "Office Button" / Button "Access Options" / "Current Database" / "Ribbon and Toolbar Options" / "Allow Build-in Toolbars"
Select your menubar from the drop-down "Menu Bar".
If you open your database this way the built-in ribbons will not be shown, only your menubar:
#CMSimple hide#
Create table "USysRibbon" in your database (Instructions) with the following Ribbon XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon startFromScratch="false"> <tabs> <tab idMso="TabHomeAccess" visible="false" /> <tab idMso="TabAddIns" label="My Ribbon Tab" /> </tabs> </ribbon> </customUI>
Remark: You cannot rename the group name "Custom Toolbars"
#CMSimple hide#
No. Access ribbons cannot be manipulated or only very limited manipulation is possible.
What you can do is create your own group within an Access tab and in there you can create buttons / controls.
Create table "USysRibbon" in your database (Instructions) with following Ribbon XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon startFromScratch="false"> <tabs> <tab idMso="TabHomeAccess"> <group id="myGroup" label="My Group" insertBeforeMso="GroupViews"> <button id="myButton" label="My Button" imageMso="HappyFace"/> </group> </tab> </tabs> </ribbon> </customUI>
For Office Ribbon adjustments Patrick Schmid wrote an AddIn. Further
information: http://pschmid.net/office2007/ribboncustomizer/index.php
#CMSimple hide#
No, up to now I haven't found a way how to remove this text within user
defined Screentips / Supertips.
You can hide the screentips in the options of Access.
See: External link to Microsoft...
#CMSimple hide#
You can find the appropriate sample IconInRibbon in the download area.
#CMSimple hide#
As a rule it's insufficient only to close and reopen the current database.
To ensure that the customized Quick ACCESS Toolbar will be displayed you have to close and then restart Access.
Create a "dummy" form in the database which should be opened in the event "OnRibbonLoad" and immediately closed again.
Sub OnRibbonLoad(ribbon As IRibbonUI) ' Callbackname in XML File "onLoad" DoCmd.OpenForm "frmDummy" DoCmd.Close acForm, "frmDummy" End Sub
Your Ribbon XML must call this function:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad"> </customUI>
Be aware not to start your database with a double click from the Explorer.
You can find a sample database in the download area.
#CMSimple hide#
No.
However, you can disable the button. Therefore you have to insert to your XML some lines of code as shown in the example below:
Example XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <!-- Insert here --> <commands> <command idMso="Help" enabled="false"/> </commands> <!-- Here your code is going on --> <ribbon startFromScratch="false"> <tabs> <tab idMso="TabHomeAccess"> <group id="myGroup" label="My Group" insertBeforeMso="GroupViews"> <button id="myButton" label="My Button" imageMso="HappyFace"/> </group> <tab> </tabs> </ribbon> </customUI>
#CMSimple hide#
Yes
Therefore use the following start tag :
<!--
and the following end tag :
-->
Sample XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <!-- This is a comment --> <ribbon startFromScratch="false"> <tabs> <tab idMso="TabHomeAccess"> <!-- This is a further comment --> <group id="myGroup" label="My Group" > <button id="myButton" label="My Button" imageMso="HappyFace"/> </group> <tab> </tabs> </ribbon> </customUI>
#CMSimple hide#
Yes.
Create a new Ribbon XML and insert lines of code as stated in the sample below :
Sample XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <commands> <command idMso= "ApplicationOptionsDialog" onAction="OnActionOptionsButton"/> </commands> <ribbon startFromScratch="false"> <!-- Here your XML code is going on --> </ribbon> </customUI>
Create the following Callback function in a standard modul:
Public Sub OnActionOptionsButton(control As IRibbonControl, ByRef cancelDefault) DoCmd.OpenForm "frmYourForm", , , , , acDialog End Sub
See Access sample database "Access-Options"
#CMSimple hide#
Insert the following Ribbon XML in the table USysRibbons:
Ribbon XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon startFromScratch="true"> </ribbon> </customUI>
#CMSimple hide#
The following Code hide the Ribbon (with Office Menü):
DoCmd.ShowToolbar "Ribbon", acToolbarNo
View Ribbon:
DoCmd.ShowToolbar "Ribbon", acToolbarYes
#CMSimple hide#
With following code you can identify the Ribbon state:
Function RibbonState() As Long 'Result: 0=normal, -1=autohide RibbonState = (CommandBars("Ribbon").Controls(1).Height < 100) End Function
Thanks to Sascha Trowitzsch: http://www.mosstools.de/
Or you can read the registry:
[HKEY_CURRENT_USER]\Software\Microsoft\Office\1x.0\Common\Toolbars\Access
Value Name: QuickAccessToolbarStyle
Value Data: 0 (ribbon = normal)
Value Data: 4 (ribbon = autohide)
This Sample Database shows how to set the Ribbon state by VBA.
In Access 2010 you can change the Ribbon state with:
CommandBars.ExecuteMso "MinimizeRibbon"
#CMSimple hide#
In the Immediate Window (CTRL + G) enter the following code:
CommandBars("YourCommandBar").Delete
or select on the Toolbar Menu "Delete Custom Toolbar":
#CMSimple hide#
Is it possible to use Late Binding instead of Early Binding, i.e. use Ribbons without the need for a reference to Microsoft Office ## Object Library?
Access 2007:
- No, the reference to Microsoft Office 12 Object Library is required.
Access 2010:
- Yes, Access 2010 allows Late Binding.
1. Replace:
IRibbonUI and IRibbonControl
by
Object
in all declaration statements in all modules.
2. Remove reference to "Microsoft Office 14.0 Object Library".
Remark: After removal of the reference IntelliSense will not be available for these objects any longer.
#CMSimple hide#
Am I able to use Application Ribbons for both Access versions (2007 and 2010) within one database?
Yes.
Setup Ribbon XML for all Ribbons in table USysRibbons.
Go to Options, Current Database, Ribbon and Toolbar Options, enter a Ribbon Name that does NOT exist in USysRibbons, e.g. "DBRibbon".
In a standard module add following code:
Option Compare Database Public Function fnc_LoadRibbon() Dim strProcName As String strProcName = "fnc_LoadRibbon" On Error GoTo fnc_LoadRibbon_Err Application.LoadCustomUI "DBRibbon", fnc_GetRibbon(Left(Application.Version, 2)) fnc_LoadRibbon_Exit: Exit Function fnc_LoadRibbon_Err: Select Case Err 'Case YourErrorNumber 'Resume fnc_LoadRibbon_Exit Case Else MsgBox "An error has occurred." & vbCrLf & vbCrLf & _ "In Function:" & vbTab & strProcName & vbCrLf & _ "Error number: " & vbTab & Err.Number & vbCrLf & _ "Description: " & vbTab & Err.description, vbCritical, _ "Error in " & Chr$(34) & strProcName & Chr$(34) Resume fnc_LoadRibbon_Exit End Select End Function Function fnc_GetRibbon(lngVersion As Long) As String ' ************************************************************ ' Created by : avenius ' Parameter : ' Return type : String ' Creation date : Wednesday, Aug 1, 2012 ' Comments : ' Updates : ' ' **************** Created by IDBE Tools 2010 **************** Dim strProcName As String strProcName = "fnc_GetRibbon" On Error GoTo fnc_GetRibbon_Err Dim dbs As DAO.Database Dim rst As DAO.Recordset Set dbs = CurrentDb() Select Case lngVersion Case 12 ' Read A2007 Ribbon Set rst = dbs.OpenRecordset("SELECT * FROM USysRibbons WHERE RibbonName='A2007'", dbOpenDynaset) Case 14 ' Read A2010 Ribbon Set rst = dbs.OpenRecordset("SELECT * FROM USysRibbons WHERE RibbonName='A2010'", dbOpenDynaset) Case Else ' Read default Ribbon Set rst = dbs.OpenRecordset("SELECT * FROM USysRibbons WHERE RibbonName='Default'", dbOpenDynaset) End Select rst.MoveFirst fnc_GetRibbon = rst.Fields("RibbonXml") fnc_GetRibbon_Exit: rst.Close Set rst = Nothing Set dbs = Nothing Exit Function fnc_GetRibbon_Err: Select Case Err 'Case YourErrorNumber 'Resume fnc_GetRibbon_Exit Case Else MsgBox "An error has occurred." & vbCrLf & vbCrLf & _ "In Function:" & vbTab & strProcName & vbCrLf & _ "Error number: " & vbTab & Err.Number & vbCrLf & _ "Description: " & vbTab & Err.description, vbCritical, _ "Error in " & Chr$(34) & strProcName & Chr$(34) Resume fnc_GetRibbon_Exit End Select End Function
Make sure function "fnc_LoadRibbon" will be loaded by Autoexec macro.
This sample is available as download.
Special thanks for the inspiration to Albert Kallal and Graham Mandeno.
#CMSimple hide#