Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, April 4, 2018 10:16 PM | 1 vote
Hi all,
Apologies in advance, I'm new and I'm going to ask dumb questions.
I'm trying to load a customUI ribbon the USysRibbons way using this XML:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="UserMain" label="Main Menu" visible="true">
<group id="CompanyInfo" label="Persephone"/>
<group id="MenuButtons" label="Navigation Pannel">
<button id="TankView" label="Tank View" imageMso="InsertBookmarkSpd"
tag="fTankView" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Open Tank View"/>
<button id="NewBrewDay" label="New Brew" imageMso="AddWebPartConnection"
tag="fNewBrewDay" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Create a new brew day"/>
<button id="BatchManager" label="Batch Manager" imageMso="NetworkDiagramGallery"
tag="fMBN" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Open Batch Manager"/>
<button id="Inventory" label="Inventory" imageMso="EditWorkflowTask"
tag="fInventoryMenu" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Open Inventory Menu"/>
<button id="NewBrand" label="Brands" imageMso="PictureBrightnessGallery"
tag="fBrands" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Create and edit beer and cider recipes"/>
<button id="Employees" label="Employees" imageMso="PivotDiagramApplyShape"
tag="fEmployees" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Add and edit employees"/>
<button id="Reports" label="Reports" imageMso="RuleLinesWide"
tag="fReportMenu" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Open Reports and Data Analysis Menu"/>
<button id="Calendar" label="Calendar" imageMso="CalendarsGallery"
tag="fCalendar" onAction="ribOpenForm" getEnabled="ControlEnabled"
size="large" supertip="Open sensory and archive testing calendars"/>
</group>
<group id="ExitApp" label="Exit Kettletown">
<button idMso="FileCompactAndRepairDatabase" label="Compact and Repair" size="large" enabled="true"
supertip="Maintain the health of your database by compacting and repairing"/>
<button idMso="FileExit" label="Exit" enabled="true" size="large"/>
</group>
</tab>
<tab id="UserTools" label="Tools" visible="true">
<group idMso="GroupWindowAccess"/>
<group idMso="GroupSortAndFilter"/>
<group idMso="GroupClipboard"/>
<group idMso="GroupTextFormatting"/>
<group idMso="GroupRichText"/>
<group idMso="GroupExport"/>
</tab>
</tabs>
</ribbon>
</customUI>
and this VBA:
in modRibbons
Option Compare Database
Option Explicit
Public globalRibbon As IRibbonUI
'Get a global reference to the ribbon object when the ribbon loads
Public Sub OnRibbonLoad(ByVal ribbon As IRibbonUI)
Set globalRibbon = ribbon
End Sub
'Open the form that is specified in the ribbon control's tag property
Public Sub ribOpenForm(control As IRibbonControl)
DoCmd.OpenForm (control.Tag)
End Sub
'Tell a ribbon control whether it should be enabled
Public Sub ControlEnabled(control As IRibbonControl, ByRef enabled)
Select Case control.ID
Case "TankView"
If CurrentProject.AllForms("fTankView").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "NewBrewDay"
If CurrentProject.AllForms("fNewBrewDay").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "BatchManager"
If CurrentProject.AllForms("fMBN").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "Inventory"
If CurrentProject.AllForms("fInventoryMenu").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "NewBrand"
If CurrentProject.AllForms("fBrands").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "Employees"
If CurrentProject.AllForms("fEmployees").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "Reports"
If CurrentProject.AllForms("fReportMenu").IsLoaded Then
enabled = False
Else
enabled = True
End If
Case "Calendar"
If CurrentProject.AllForms("fCalendar").IsLoaded Then
enabled = False
Else
enabled = True
End If
End Select
End Sub
And in the FormLoad() and FormClose() Subs of each of the above mentioned forms (tabs)
Option Compare Database
Option Explicit
Private Sub Form_Load()
If Not globalRibbon Is Nothing Then
globalRibbon.InvalidateControl ("Employees")
End If
End Sub
Private Sub Form_Close()
If Not globalRibbon Is Nothing Then
globalRibbon.InvalidateControl ("Employees")
End If
End Sub
*fEmployees shown as example... because there isn't anything else on this form yet.
Under Access Options > Current Database > Ribbon and Toolbar Options I've set Ribbon Name to 'User' (1 of 2 records in USysRibbons, 'Developer' and 'User' are the ribbonName s. The only difference in XML is startFromScratch="false" and "true", respectively.) and unchecked both 'Allow full Menus' and 'Allow Default Shortcut Menus'.
PROBLEM:
When I open the database I get the following error messages:
- Custom UI Runtime Error in [dbFileLocation]. Error found in Custom UI XML of [dbFileLocation]. Line 1, column 5. Error code 0x80004005. Unknown Element: div.
- Custom UI Runtime Error in [dbFileLocation]. Error found in Custom UI XML of [dbFileLocation]. Line 1, column 17. Error code 0xC00CEE24. Quote explected.
I get each error message twice (once for each USysRibbon I assume), and they both point to the first line.
I'm using visual studio as an XML editor and it doesn't pick up any errors, but it also doesn't recognize the shema.
All help is appreciated. Let me know if I need to give more info.
Thanks!
All replies (6)
Thursday, April 5, 2018 9:52 PM âś…Answered
Strange! Your XML is correct as posted. Are you sure this is the same in the UsysRibbon table?
The Error message implies you have some HTML <div> block. Perhaps you have pasted Rich text from your editor?
Brian, ProcessIT- Hawke`s Bay, New Zealand
Thursday, April 5, 2018 1:03 AM
Hi,
Just in the off chance the 2007 schema is causing some problems, have you tried using the other schema?
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
Just a thought...
Thursday, April 5, 2018 1:20 AM
Yep. Same error messages.
I also tried skimming the XML down to just ids and labels (no imgs or ribbon functions) with both the 2007 and 2010 shema. Same error messages.
Do I maybe need a reference file that isn't linked or something?
Thursday, April 5, 2018 2:35 AM
I carefully recreated your scenario, and did not get any errors.
Tested both A2010 and A2016.
Maybe you can try on another machine?
I can upload my test file if you like.
-Tom. Microsoft Access MVP
Thursday, April 5, 2018 4:00 AM
Interesting. Ok, thanks for doing all of that. I'll try it out on a different machine and hunt down the problem.
Thursday, April 5, 2018 11:52 PM
Yes! That was the problem. I had the XML field set to rich text for some reason.
Thank you!