How to execute macro when selecting user-defined menu in ribbon

M

Mathieu936

Hi!

I would like to know how to automatically execute a macro when I
select a user-defined tab I created in my Excel ribbon.

I tried onAction tag in my ribbon code for my menu:
<menu id="DropdownBD7020" label="BM7020" size="large"
imageMso="ControlsGallery" onAction="MacroName" >

but that doesn't work.


Thanks!
 
B

Bob Phillips

Matthieu,

I take it you are creating a dropdown in the ribbon in XML.

Can you post the whole XML and the callback code that you have?
 
M

Mathieu936

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/
customui">
<ribbon>
<tabs>
<!-- Add-Ins Ribbon Menu -->
<tab id="SpecialFunctionsTab" label="My Special Functions">

<!-- Structural Analysis Library Tools Group -->
<group id="GroupBD7020" label="BM7020" >


<!-- BD7020 Dropdown -->
<menu id="DropdownBD7020" label="BM7020 Manual" size="large"
imageMso="ControlsGallery" >

<menu id="Menu01GeneralInformation" label="01 General
Information" >
<menu id="Menu02StressReportFormat" label="02 Stress
Report Format" >
<button id="ReportPWC" label="Stress Report"
onAction="InsertTool" />
</menu>
</menu>

</menu>

</group>
</tab>
</tabs>
</ribbon>
</customUI>
 
M

Mathieu936

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/
customui">
 <ribbon>
    <tabs>
      <!-- Add-Ins Ribbon Menu -->
      <tab id="SpecialFunctionsTab" label="My Special Functions">

         <!-- Structural Analysis Library Tools Group -->
         <group id="GroupBD7020" label="BM7020" >

          <!-- BD7020 Dropdown -->
          <menu id="DropdownBD7020" label="BM7020 Manual" size="large"
imageMso="ControlsGallery" >

            <menu id="Menu01GeneralInformation" label="01General
Information" >
               <menu id="Menu02StressReportFormat" label="02 Stress
Report Format" >
                     <button id="ReportPWC" label="Stress Report"
onAction="InsertTool" />
                   </menu>
                </menu>

            </menu>

         </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

any idea?

I would like to change the line <tab id="SpecialFunctionsTab"
label="My Special Functions"> for <tab id="SpecialFunctionsTab"
label="My Special Functions" onAction="MyMacro">

However it does'nt work. I tried onAction, onClick, onSelect,
onActivate but nothing works :-(
 
J

Jon Peltier

If you use a dynamicMenu tag instead of a menu tag, you name a callback
that runs VBA to generate the menu. Within this VBA you could call the
other code you want to run.

I don't know the details off the top of my head, but i made it work
recently based on what's in the book RibbonX by Hennig, Martin, and Puls.

- Jon
 
M

Mathieu936

If you use a dynamicMenu tag instead of a menu tag, you name a callback
that runs VBA to generate the menu. Within this VBA you could call the
other code you want to run.

I don't know the details off the top of my head, but i made it work
recently based on what's in the book RibbonX by Hennig, Martin, and Puls.

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
774-275-0064http://peltiertech.com/







- Afficher le texte des messages précédents -

Okay thanks, I'll check what I can do..
 
B

Bob Phillips

I tried to create a workbook with your XML, but it didn't generate the
ribbon for some reason.

--

HTH

Bob

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/
customui">
<ribbon>
<tabs>
<!-- Add-Ins Ribbon Menu -->
<tab id="SpecialFunctionsTab" label="My Special Functions">

<!-- Structural Analysis Library Tools Group -->
<group id="GroupBD7020" label="BM7020" >

<!-- BD7020 Dropdown -->
<menu id="DropdownBD7020" label="BM7020 Manual" size="large"
imageMso="ControlsGallery" >

<menu id="Menu01GeneralInformation" label="01 General
Information" >
<menu id="Menu02StressReportFormat" label="02 Stress
Report Format" >
<button id="ReportPWC" label="Stress Report"
onAction="InsertTool" />
</menu>
</menu>

</menu>

</group>
</tab>
</tabs>
</ribbon>
</customUI>

any idea?

I would like to change the line <tab id="SpecialFunctionsTab"
label="My Special Functions"> for <tab id="SpecialFunctionsTab"
label="My Special Functions" onAction="MyMacro">

However it does'nt work. I tried onAction, onClick, onSelect,
onActivate but nothing works :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top