3

I have some problems configuring my ribbon.

  1. Only macros are working as onAction or getPressed attributes. Functions in standard modules don't work. Callbacks written in standard modules don't work either.
  2. How can I use the value of edit box in VBA function?

This is xml of my ribbon for example:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon startFromScratch="true">
        <tabs>
            <tab idMso="TabHome">
                <group idMso="GroupFont" visible="false" />
            </tab>
            <tab id="CustomTab" label="Клиенты">
                <group id="PeopleGroup" label="Люди">
                    <toggleButton id="ToggleButton1" size="large" label="Все люди"
                      onAction="Pplopenmacro" imageMso="ContactPictureMenu"/>
                    <editBox id="PeopleEditBox"
                             label="Поиск по рег№" 
                             onChange="MyEditBoxCallbackOnChange" />
                    <button id="Button3" label="TEST"
                      size="normal" onAction="=Person_choose()"  />
                </group>
                <group id="CompaniesGroup" label="Компании">
                    <toggleButton id="ToggleButton2" size="large"
                      label="Компании"
                      onAction="Cmpnopenmacro" imageMso="MeetingsWorkspace" />
                </group>
            </tab>
            <tab id="CustomTab2" label="Документы">
                <group id="MyGroup" label="Документы" >
                    <button id="Button1" label="Счета"
                      size="large" onAction="Invoiceopenmacro"
                      imageMso="BusinessFormWizard" />
                    <button id="Button2" label="Хуета" size="normal" />
                </group >
            </tab>
        </tabs>
    </ribbon>
</customUI>

And these are my functions in std module:

Public Sub MyEditBoxCallbackgetText(control As IRibbonControl, ByRef strText)
    ' Callback EditBox

    '  Select Case control.Id
    '      Case "PeopleEditBox"
    '          strText = "Hello World"
    '  End Select

    MsgBox "1"
End Sub

Public Sub MyEditBoxCallbackOnChange(control As IRibbonControl, strText As String)
    ' Callback Editbox: Returnvalue Editbox

    '  Select Case control.Id
    '      Case "PeopleEditBox"
    '              MsgBox "Value Editbox: " & _
    '              strText, vbInformation, "Sample EditBox"
    '  End Select

    MsgBox "2"
End Sub

Public Sub Person_choose()
    'DoCmd.openForm "People", acNormal
     MsgBox "Yahoo!"
End Sub
Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
iamx4nd3r
  • 81
  • 1
  • 6

1 Answers1

3

You may need to tell XML where the procedure can be found. Example -

<group id="PeopleGroup" label="People">
    <toggleButton id="ToggleButton1" size="large"
      label="All People"
      onAction="ThisWorkbook.Pplopenmacro" imageMso="ContactPictureMenu"/>
    <editBox id="PeopleEditBox"
             label="Search by Region #" 
             onChange="ThisWorkbook.MyEditBoxCallbackOnChange" />
    <button id="Button3" label="TEST"
      size="normal" onAction="ThisWorkbook.Person_choose()"  />
</group>

ThisWorkbook. means that the procedures are found in the ThisWorkbook object (see your Project Explorer in the VBA editing window)

I have never put the callbacks into a standard module, but since you are doing that maybe you need to have something like onAction="MyModuleName.Pplopenmacro" in the XML?

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118