View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default .OnAction set value

Id is a read only property. You can use the TAG or PARAMETER properties.


If you use TAG, then you can search for it using FindControl/Findcontrols
--
regards,
Tom Ogilvy


"Arne Hegefors" wrote:

Hello Tom! Great! Thanks for your help! Now I use cmdBtn.Caption to identify
the button but is there no better way of adding an id to a button? I tried
assigning an ID to the button by writing:

With linjeDiagramKnapp
.ID = "linje"
.Caption = "Linjediagram"

but when I check the id in msgbox all I get is 1. Is there no way of
assgning a descriptive ID but not using caption (you may want to chnage
caption so it does not feel that secure). Please help me out! Thanks very
much!
"Tom Ogilvy" skrev:

in ArrayLoop you can get a reference to the button with

set cmdBtn = Application.Commandbars.ActionControl

so you don't need a global variable or to pass anything.

--
Regards,
Tom Ogilvy



"Arne Hegefors" wrote:

In my macro when the user presses a button I use the following code:

Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Caption = "Stapeldiagram"
.OnAction = "ChartModul1.arrayLoop"
....here I want to assign a value to a global variable (declared in a
differen place) so that I can keep track of which button is pressed.
Alternatively I can assign a value to an "ordinary" variable and pass that
along to the other modules as an argumnet. Can someone please help me with
the code for this? Thanks to you all very much!