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

I have a small problem that is of greate importance to me and seem to have a
hard time getting any help. I have two modules. in the first module i have
code that creates buttons. if a button is pressed then a sub in ANOTHER
module is called. that works fine. in that sub i want to check which button
has been pressed. therefore i need to look at the tag for the button. it is
here that my code fails. i do not know how to do this when the button is
created in another module than the sub. that is all i am asking. My code for
the first module:

Public Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim linjeDiagramKnapp As CommandBarButton
Dim stapelDiagramKnapp As CommandBarButton
'stapeldiagramknapp
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.Caption = "Stapeldiagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
End With
'slut stapeldiagramknapp

.........some more buttons..........

in ANOTHER MODULE:

Public Sub arrayLoop()
Dim obj As Object
Dim currentChart As Object

Select Case CommandBars.ActionControl.Tag
Case "linje"
MsgBox ("linje button clicked.")
Case "stapel"
MsgBox ("stapel button clicked.")
Case ""
MsgBox ("empty")
End Select

I do not get any tag, it is always "". thus, there must be a probelm with
the fact that they are in different modules. please help me! i have know idea
how to write this nor how to find info that tells you how to do it. it is
really important to me. any help appreciated! thanks alot!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default tag different modules

can't really check your code, but i know if you create the buttons, or textbox
or anything else with controls.add, you use the "!" instead of the "." .

so
me.textbox1.value
would be
me!textbox1.value

maybe this will help.
--


Gary


"Arne Hegefors" wrote in message
...
I have a small problem that is of greate importance to me and seem to have a
hard time getting any help. I have two modules. in the first module i have
code that creates buttons. if a button is pressed then a sub in ANOTHER
module is called. that works fine. in that sub i want to check which button
has been pressed. therefore i need to look at the tag for the button. it is
here that my code fails. i do not know how to do this when the button is
created in another module than the sub. that is all i am asking. My code for
the first module:

Public Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim linjeDiagramKnapp As CommandBarButton
Dim stapelDiagramKnapp As CommandBarButton
'stapeldiagramknapp
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.Caption = "Stapeldiagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
End With
'slut stapeldiagramknapp

........some more buttons..........

in ANOTHER MODULE:

Public Sub arrayLoop()
Dim obj As Object
Dim currentChart As Object

Select Case CommandBars.ActionControl.Tag
Case "linje"
MsgBox ("linje button clicked.")
Case "stapel"
MsgBox ("stapel button clicked.")
Case ""
MsgBox ("empty")
End Select

I do not get any tag, it is always "". thus, there must be a probelm with
the fact that they are in different modules. please help me! i have know idea
how to write this nor how to find info that tells you how to do it. it is
really important to me. any help appreciated! thanks alot!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default tag different modules

No I am sorry I create the buttons in my code using:

Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)

as I wrote. When I try to get the tag I write:

Select Case CommandBars.ActionControl.Tag

I tried changing the "." to "!" as you suggested but that gave me just
error. I dont understand it cannot be that hard to refer to another module,
what am I missing? I have shopped around in books and so but they have not
given me any guidance. If it is not possible please let me know (although I
doubt that that is the case). I have been spening half a day on this and I
have not come any closer to solving it. Please if anyone has any idea how to
do it please help me. Remeber I am just asking how to get the tag from a
button created in another module, nothing else. Thank you all for your help!

"Gary Keramidas" skrev:

can't really check your code, but i know if you create the buttons, or textbox
or anything else with controls.add, you use the "!" instead of the "." .

so
me.textbox1.value
would be
me!textbox1.value

maybe this will help.
--


Gary


"Arne Hegefors" wrote in message
...
I have a small problem that is of greate importance to me and seem to have a
hard time getting any help. I have two modules. in the first module i have
code that creates buttons. if a button is pressed then a sub in ANOTHER
module is called. that works fine. in that sub i want to check which button
has been pressed. therefore i need to look at the tag for the button. it is
here that my code fails. i do not know how to do this when the button is
created in another module than the sub. that is all i am asking. My code for
the first module:

Public Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim linjeDiagramKnapp As CommandBarButton
Dim stapelDiagramKnapp As CommandBarButton
'stapeldiagramknapp
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.Caption = "Stapeldiagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
End With
'slut stapeldiagramknapp

........some more buttons..........

in ANOTHER MODULE:

Public Sub arrayLoop()
Dim obj As Object
Dim currentChart As Object

Select Case CommandBars.ActionControl.Tag
Case "linje"
MsgBox ("linje button clicked.")
Case "stapel"
MsgBox ("stapel button clicked.")
Case ""
MsgBox ("empty")
End Select

I do not get any tag, it is always "". thus, there must be a probelm with
the fact that they are in different modules. please help me! i have know idea
how to write this nor how to find info that tells you how to do it. it is
really important to me. any help appreciated! thanks alot!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default tag different modules

Works fine for me Arne.

Are you sure arrayLoop is in module ChartModul1?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Arne Hegefors" wrote in message
...
I have a small problem that is of greate importance to me and seem to have

a
hard time getting any help. I have two modules. in the first module i have
code that creates buttons. if a button is pressed then a sub in ANOTHER
module is called. that works fine. in that sub i want to check which

button
has been pressed. therefore i need to look at the tag for the button. it

is
here that my code fails. i do not know how to do this when the button is
created in another module than the sub. that is all i am asking. My code

for
the first module:

Public Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim linjeDiagramKnapp As CommandBarButton
Dim stapelDiagramKnapp As CommandBarButton
'stapeldiagramknapp
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.Caption = "Stapeldiagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
End With
'slut stapeldiagramknapp

........some more buttons..........

in ANOTHER MODULE:

Public Sub arrayLoop()
Dim obj As Object
Dim currentChart As Object

Select Case CommandBars.ActionControl.Tag
Case "linje"
MsgBox ("linje button clicked.")
Case "stapel"
MsgBox ("stapel button clicked.")
Case ""
MsgBox ("empty")
End Select

I do not get any tag, it is always "". thus, there must be a probelm with
the fact that they are in different modules. please help me! i have know

idea
how to write this nor how to find info that tells you how to do it. it is
really important to me. any help appreciated! thanks alot!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default tag different modules

Actually, it is not necessary to include the module name if it is a standard
code module.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Works fine for me Arne.

Are you sure arrayLoop is in module ChartModul1?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Arne Hegefors" wrote in message
...
I have a small problem that is of greate importance to me and seem to

have
a
hard time getting any help. I have two modules. in the first module i

have
code that creates buttons. if a button is pressed then a sub in ANOTHER
module is called. that works fine. in that sub i want to check which

button
has been pressed. therefore i need to look at the tag for the button. it

is
here that my code fails. i do not know how to do this when the button is
created in another module than the sub. that is all i am asking. My code

for
the first module:

Public Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim linjeDiagramKnapp As CommandBarButton
Dim stapelDiagramKnapp As CommandBarButton
'stapeldiagramknapp
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.Caption = "Stapeldiagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
End With
'slut stapeldiagramknapp

........some more buttons..........

in ANOTHER MODULE:

Public Sub arrayLoop()
Dim obj As Object
Dim currentChart As Object

Select Case CommandBars.ActionControl.Tag
Case "linje"
MsgBox ("linje button clicked.")
Case "stapel"
MsgBox ("stapel button clicked.")
Case ""
MsgBox ("empty")
End Select

I do not get any tag, it is always "". thus, there must be a probelm

with
the fact that they are in different modules. please help me! i have know

idea
how to write this nor how to find info that tells you how to do it. it

is
really important to me. any help appreciated! thanks alot!





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
Public, Private, Event modules, Forms modules,,, Jim May Excel Programming 11 October 31st 05 03:12 AM
Basic question - modules and class modules - what's the difference? Mark Stephens[_3_] Excel Programming 9 May 8th 05 11:48 AM
Modules and add-ins SmilingPolitely[_3_] Excel Programming 2 April 7th 05 04:53 AM
When to code in sheet or userform modules and when to use modules Tony James Excel Programming 1 December 16th 04 10:02 PM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM


All times are GMT +1. The time now is 05:02 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"