Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default .OnAction set value

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default .OnAction set value

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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default .OnAction set value

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
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!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default .OnAction set value

Hi Tom! Lst question I hope. My commandbar is created in another module than
where i have the sub that checks the value of the commanbar.

In the module Meny:

Dim stapelDiagramKnapp As CommandBarButton
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
......

In the module ChartModul:

Set cmdBtn = Application.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("it is a stapel")
End If

My problem is that the code does not find any value for the Tag. I assume
that I have to change the code for Application.Command.......but I do not
know how to write it so that it gets the tag value. please please please help
me out here! I hope I dont have to ask any more questions after this! I truly
appreciate all your help! Thanks very much!


"Tom Ogilvy" skrev:

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!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default .OnAction set value

Sub abcd()
Dim stapelDiagramKnapp As CommandBarButton
With CommandBars("Custom 1")
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
End With
With stapelDiagramKnapp
.Caption = "Test Button"
.Tag = "stapel"
.OnAction = "Module2.btnclk"
End With
End Sub

Sub btnclk()
Dim cmdBtn As CommandBarButton
Set cmdBtn = Application.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("it is a stapel")
End If
End Sub


worked fine for me.

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

Hi Tom! Lst question I hope. My commandbar is created in another module than
where i have the sub that checks the value of the commanbar.

In the module Meny:

Dim stapelDiagramKnapp As CommandBarButton
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.....

In the module ChartModul:

Set cmdBtn = Application.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("it is a stapel")
End If

My problem is that the code does not find any value for the Tag. I assume
that I have to change the code for Application.Command.......but I do not
know how to write it so that it gets the tag value. please please please help
me out here! I hope I dont have to ask any more questions after this! I truly
appreciate all your help! Thanks very much!


"Tom Ogilvy" skrev:

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!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default .OnAction set value

Hello again! Thanks for your reply! I did not work for me. Then I deleted
another module that i was not using and then it all of a sudden started to
work...I really am not getting this programing. Thank you very much for all
your help Tom! I do not know what I would have done otherwise! Again thank
you very much!!!!


"Tom Ogilvy" skrev:

Sub abcd()
Dim stapelDiagramKnapp As CommandBarButton
With CommandBars("Custom 1")
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
End With
With stapelDiagramKnapp
.Caption = "Test Button"
.Tag = "stapel"
.OnAction = "Module2.btnclk"
End With
End Sub

Sub btnclk()
Dim cmdBtn As CommandBarButton
Set cmdBtn = Application.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("it is a stapel")
End If
End Sub


worked fine for me.

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

Hi Tom! Lst question I hope. My commandbar is created in another module than
where i have the sub that checks the value of the commanbar.

In the module Meny:

Dim stapelDiagramKnapp As CommandBarButton
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.....

In the module ChartModul:

Set cmdBtn = Application.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("it is a stapel")
End If

My problem is that the code does not find any value for the Tag. I assume
that I have to change the code for Application.Command.......but I do not
know how to write it so that it gets the tag value. please please please help
me out here! I hope I dont have to ask any more questions after this! I truly
appreciate all your help! Thanks very much!


"Tom Ogilvy" skrev:

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!

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
OnAction? Pixie Excel Programming 2 July 1st 05 01:35 PM
onAction with parameters Alfonso Sanz Excel Programming 1 June 23rd 05 09:52 AM
.OnAction with arguments max Excel Programming 4 February 23rd 04 06:30 PM
OnAction Jim Rech Excel Programming 1 September 5th 03 04:39 PM
OnAction Richard Yang Excel Programming 1 July 15th 03 01:37 PM


All times are GMT +1. The time now is 06:37 PM.

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

About Us

"It's about Microsoft Excel"