Ribbon Issues

NigelShaw

Registered User.
Local time
Today, 19:49
Joined
Jan 11, 2008
Messages
1,575
Hi,

I am having issues with ribbon!!

here is what i have-
To set up the ribbon
Code:
Option Compare Database
Option Explicit

Public bolGrpInfo As Boolean
Public bolGrpContact As Boolean
Public bolGrpPriceList As Boolean

Public glngItemCount As Long
Public bolContactList As Variant

Public gobjRibbon As IRibbonUI
'Public strMenuID As String  'Updateable on every menu change


Public Sub OnRibbonLoad(ribbon As IRibbonUI)
    'Callbackname im XML File "onLoad"
    
    Set gobjRibbon = ribbon

    bolGrpInfo = True
    bolGrpContact = True
    bolGrpPriceList = True

    
End Sub

My AutoExec opens the form frmTest, here is the onLoad code-
Code:
Private Sub Form_Load()
MainMenu
End Sub
The MainMenu routine called shows the groups that are set to visible = true
Code:
Public Sub MainMenu()
    
    bolGrpInfo = True
    bolGrpContact = True
    bolGrpPriceList = True
    
    Call RibbonInvalidate
   
End Sub

Public Sub RibbonInvalidate()

    gobjRibbon.InvalidateControl "grpContacts"
    gobjRibbon.InvalidateControl "grpPriceList"
    gobjRibbon.InvalidateControl "grpInfo"
This controls the visibility state
Code:
Public Sub GetVisible(control As IRibbonControl, ByRef visible)

    Select Case control.ID

    Case "grpInfo"
        visible = bolGrpInfo
    Case "grpContacts"
        visible = bolGrpContact
    Case "grpPriceList"
        visible = bolGrpPriceList

    Case Else
        visible = True
    End Select
End Sub
Code:
Sub OnActionButton(control As IRibbonControl)
   
            MsgBox "Place for Action"

End Sub
This is my XML
Code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon startFromScratch="true">
        <tabs>
      <tab id="tab0" label="Home" getVisible ="GetVisible">
        <group id="grpInfo" label="User" getVisible ="GetVisible">
          <labelControl id="lblToday" label="lblToday" getVisible="GetVisible" />
          <labelControl id="lblLoggedIn" label="lblLoggedIn" getVisible="GetVisible"  />
        </group>
        <group id="grpContacts" label="Contacts" getVisible ="GetVisible">
          <button id="btnNewContact" size="large" label="New Contact" imageMso="DistributionListAddNewMember" onAction="OnActionButton" getVisible="GetVisible"  />
          <button id="btnEditContact" size="large" label="Edit Contact" imageMso="DirectRepliesTo" onAction="OnActionButton" getVisible="GetVisible"  />
        </group>
        <group id="grpPriceList" label="Price List" getVisible ="GetVisible">
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

the error i get is

attachment.php


Any ideas as there is very little ribbon and code and i can't see why i would get the error. The error message is
attachment.php


Cheers

Nigel
 

Attachments

  • Error.JPG
    Error.JPG
    24 KB · Views: 1,150
  • error2.JPG
    error2.JPG
    19.9 KB · Views: 1,201
I keep global object variables in a hidden form that I re-expose as global properties, so on a hidden form, maybe named 'SystemForm' I'll have...
Code:
private m_ribbon as IRibbonUI

Property Get Ribbon as IRibbonUI
  Set Ribbon = m_ribbon
End Property
Property Let Ribbon(Value as IRibbonUI)
  Set m_ribbon = Value
End Property
In a standard module I'll handle the ribbon onLoad, so ...
Code:
Public Sub OnRibbonLoad(Ribbon as IRibbonUI)
  Set SysForm.Ribbon = Ribbon
End Sub
And then in a standard module globally expose the ribbon, and the hidden form containining system objects, like ...
Code:
Public Property Get Ribbon as IRibbonUI
  Set Ribbon = SysForm.Ribbon
End Property

Public Property Get SysForm as Form_SystemForm
  Const FN = "SystemForm"
  If Not CurrentProject.AllForms(FN).IsLoaded Then DoCmd.OpenForm FN
  Set SysForm = Forms(FN)
End Property
It always seemed to me that public variables in standard modules were not that stable, particulary objects, so I commonly do something like the above. Cheers,
Mark
 

Users who are viewing this thread

Back
Top Bottom