View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Returning values from OnAction

In an OnAction macro
Dim ctr as Object
Set ctr CommandBars.ActionControl

If you are sure your macro will only be called by a CommandBarButton, which
is typically though not necessarily the case, to get the intellisense
declare

Dim ctr as CommandBarButton

you can read/write properties from/to ctr, eg

Select case ctr.Caption ' or maybe ctr.Tag
case "myMacro1"
myMacro1
ctr.State = msoButtonDown


Regards,
Peter T

"Trooper" wrote in message
...
I am using Excel 2003, and Visual Basic for Applications. (I've been

using a
reference book written in 1994, but have looked online and through the VBA
help material extensively.)

I have managed to write code to place a custom menu on the Worksheets Menu
Bar, add two popup controls, "Go To" and "Print", and add the names of the
worksheets of the workbook to each as control buttons. But, I can't

figure
out how to return values from a control. I know I can use OnAction to run

a
procedure, but I want to know, for example, the Caption of the button that
was clicked. (Just getting the index number of the clicked button would
probably help, but then I'd have to figure out how to translate that index
number into the caption. But, I would be happy to know how to get both

the
caption and the index, just for future reference.

Thanks!!!