Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Ribbon - custom button calls macro with argument

Hi guys

In XL2003 with custom toolbars, I could assign an OnAction macro with
an argument, something like .OnAction = "'MyMacro "SomeArgumentHere"'"

From memory, the argument is wrapped in double quotes, the entire
macro and argument is wrapped in single quotes and double quotes
around that. It might have been slightly different, but you get the
idea.

What I'm trying to do now is, in XL2007, customise the ribbon
similarly. But the syntax in XML is different and I'm wondering how
you wrap the argument. Any suggestions are appreciated.

Thanks in advance

Paul Martin
Melbourne, Australia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Ribbon - custom button calls macro with argument

Thanks for the reply Andy, though I don't fully understand your
suggestion. What I'm trying to do is capture the user's selection in
a combobox and use that selection as the criteria for what a procedure
performs. Any suggestions?

Thanks in advance

Paul
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Ribbon - custom button calls macro with argument

Hi,

So if I understand, you have a button that will run different macros
depending upon the current selected item of a dropdown control.
In which case you need to use a call back to get the dropdown item.

vba code.
Public Sub Dropdown1_onAction(control As IRibbonControl, id As String, index
As Integer)
'
' Code for onAction callback. Ribbon control dropDown
'
MsgBox "You selected ID=" & id & vbLf & "Index=" & index, vbInformation,
"onAction Callback"

End Sub

xml for new group on home tab. Dropdown has 3 items, Cat, Dog and Fish.

<!--RibbonX Visual Designer 1.6 for Microsoft Excel. XML Code produced on
2009/11/18--
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
<ribbon
<tabs
<tab idMso="TabHome"
<group
id="Group1"
label="Group1"
<dropDown
id="Dropdown1"
label="Pick Me"
getItemLabel="Dropdown1_getItemLabel"
onAction="Dropdown1_onAction"
<item
id="itmCat"
label="Cat"/
<item
id="itmDog"
label="Dog"/
<item
id="itmFish"
label="Fish"/
</dropDown
</group
</tab
</tabs
</ribbon
</customUI

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Paul Martin" wrote in message
...
Thanks for the reply Andy, though I don't fully understand your
suggestion. What I'm trying to do is capture the user's selection in
a combobox and use that selection as the criteria for what a procedure
performs. Any suggestions?

Thanks in advance

Paul


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Ribbon - custom button calls macro with argument

Thanks Andy. I'm actually working through your Ribbon Add-In, which
looks very useful. I'll post back if I get stuck. Thanks again.

Paul
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Ribbon - custom button calls macro with argument

FWIW, I didn't really like the idea of using the Tag property.
Initially it looked like a quick-fix, but an unnecessary one. Having
selected a dropdown item, surely there's a way of capturing that
selection without having to double-handle the value by entering it in
the XML as a Tag property.

My dropdowns are populated by values in cell ranges so, given that the
dropdown captures the selection's index (base 0), I can use index + 1
as the pointer to the cell in the range. Hopefully that might assist
someone who is searching for a solution to my problem.

Paul
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Macro to Ribbon Button Tim Excel Programming 6 August 1st 09 03:21 PM
no custom button in ribbon Birgit[_2_] Excel Programming 3 February 21st 08 03:41 PM
Macro Fault on Custom Ribbon Karen[_13_] Excel Programming 5 January 23rd 08 07:32 PM
error running macro from Ribbon button [email protected] Excel Programming 1 January 6th 08 11:50 AM
Hyperlink calls macro passing argument Jeff Excel Programming 3 November 10th 06 10:11 PM


All times are GMT +1. The time now is 02:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"