Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default change in combobox not firing

Hi all,

I have a pop-up (right-click) menu that I'm creating on the fly based on
what object my user right-clicks on, and everything seems to be working ok
except that when I add a control of type msocontrolcombobox, I can't trap
the _change event.

I have a class module for the menu with several Private WithEvents
commandbarbuttons that are working, followed by :
Private WithEvents btnSetTarget As CommandBarComboBox

Private Sub btnSetTarget_Change(ByVal Ctrl As Office.CommandBarComboBox)
Debug.Print Ctrl.Text
(I'd like to put more substatial code here)
End Sub

and in the code to show the pop-up:
public sub ShowMenu()
With Application.CommandBars.Add( Position:=msoBarPopup)
....
other buttons defined
....
Set btnSetTarget = .Controls.Add(Type:=msoControlComboBox)
With btnSetTarget
.AddItem "1%", 1
.AddItem "2%", 2
.AddItem "3%", 3
.AddItem "5%", 4
.Width = 120
.Caption = "Set '" & mAxis.AxisTitle.Caption & "' Target"
End With
.ShowPopup
.Delete
End With
End Sub


As I said up above, my other buttons work fine - the click event occurs
between the .showpopup and .delete lines in the code above. However, for
btnSetTarget, the change event doesn't seem to trigger.

What's wrong?

TIA.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default change in combobox not firing

the btnsetTarget in your set statement has no relation to your btnsetTarget
in your class module. You never tie your button to the class.

Look at the help example for the change event of a commandbarcombo object to
see what I am talking about.

The only omission I saw was the example doesn't state explicitly that the
class module is named

ComboBoxHandler

Although you can tell that by looking at the code, it should be stated
clearly I would think.

Observing that, the example worked fine for me. Follow that pattern

--
Regards,
Tom Ogilvy


"Mike" wrote:

Hi all,

I have a pop-up (right-click) menu that I'm creating on the fly based on
what object my user right-clicks on, and everything seems to be working ok
except that when I add a control of type msocontrolcombobox, I can't trap
the _change event.

I have a class module for the menu with several Private WithEvents
commandbarbuttons that are working, followed by :
Private WithEvents btnSetTarget As CommandBarComboBox

Private Sub btnSetTarget_Change(ByVal Ctrl As Office.CommandBarComboBox)
Debug.Print Ctrl.Text
(I'd like to put more substatial code here)
End Sub

and in the code to show the pop-up:
public sub ShowMenu()
With Application.CommandBars.Add( Position:=msoBarPopup)
....
other buttons defined
....
Set btnSetTarget = .Controls.Add(Type:=msoControlComboBox)
With btnSetTarget
.AddItem "1%", 1
.AddItem "2%", 2
.AddItem "3%", 3
.AddItem "5%", 4
.Width = 120
.Caption = "Set '" & mAxis.AxisTitle.Caption & "' Target"
End With
.ShowPopup
.Delete
End With
End Sub


As I said up above, my other buttons work fine - the click event occurs
between the .showpopup and .delete lines in the code above. However, for
btnSetTarget, the change event doesn't seem to trigger.

What's wrong?

TIA.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default change in combobox not firing

Sorry Tom,

I should have made it more clear, but I edited out a lot of code for
brevity, ALL the code snippets that I posted ARE from the class module.

I played around with the example you suggested anyways though, and it led me
to the issue rather quickly: the example is using a floating commandbar, my
code is using a popup (rightclick shortcut) commandbar. When I convert the
example commandbar to become an msobarpopup, the example exhibits the same
failure style as my code - I guess because of the modality of the popup
commandbar tied into that it dissappears as soon as you click a button or
select a value from the combobox dropdown.

Fortunately, I have another way to deal with this, unfortunately it's not as
'slick'.

Thanks for the help.

"Tom Ogilvy" wrote in message
...
the btnsetTarget in your set statement has no relation to your

btnsetTarget
in your class module. You never tie your button to the class.

Look at the help example for the change event of a commandbarcombo object

to
see what I am talking about.

The only omission I saw was the example doesn't state explicitly that the
class module is named

ComboBoxHandler

Although you can tell that by looking at the code, it should be stated
clearly I would think.

Observing that, the example worked fine for me. Follow that pattern

--
Regards,
Tom Ogilvy


"Mike" wrote:

Hi all,

I have a pop-up (right-click) menu that I'm creating on the fly based on
what object my user right-clicks on, and everything seems to be working

ok
except that when I add a control of type msocontrolcombobox, I can't

trap
the _change event.

I have a class module for the menu with several Private WithEvents
commandbarbuttons that are working, followed by :
Private WithEvents btnSetTarget As CommandBarComboBox

Private Sub btnSetTarget_Change(ByVal Ctrl As Office.CommandBarComboBox)
Debug.Print Ctrl.Text
(I'd like to put more substatial code here)
End Sub

and in the code to show the pop-up:
public sub ShowMenu()
With Application.CommandBars.Add( Position:=msoBarPopup)
....
other buttons defined
....
Set btnSetTarget = .Controls.Add(Type:=msoControlComboBox)
With btnSetTarget
.AddItem "1%", 1
.AddItem "2%", 2
.AddItem "3%", 3
.AddItem "5%", 4
.Width = 120
.Caption = "Set '" & mAxis.AxisTitle.Caption & "'

Target"
End With
.ShowPopup
.Delete
End With
End Sub


As I said up above, my other buttons work fine - the click event occurs
between the .showpopup and .delete lines in the code above. However,

for
btnSetTarget, the change event doesn't seem to trigger.

What's wrong?

TIA.





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
Stoppoing ComboBox Change Event from firing when Multipage changes GH[_2_] Excel Programming 0 December 22nd 04 03:56 PM
Worksheet change event not firing Wexler Excel Programming 11 October 25th 04 09:45 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Change minimumscale with the change event of a combobox Herbert Chan Excel Programming 1 April 11th 04 12:43 PM
combobox change Dick Kusleika Excel Programming 0 August 21st 03 09:57 PM


All times are GMT +1. The time now is 10:51 AM.

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"