LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Toolbar Menu problems

That did the trick, Many thanks.


--
Cheers
Nigel



"keepITcool" wrote in message
.com...
Sub tbHandler()

With Application.CommandBars.ActionControl
Select Case .Parameter
Case 1: MsgBox "Do Summary"
Case 2: MsgBox "Do Targets"
Case 8: MsgBox .ListIndex & .List(.ListIndex)
End Select
End With

End Sub

also: look at naming conventions for variables...
your original had toolbars named rs (recordset?)
below has a worksheet named ctl (control).
also: dim your variables at the top of the procedure.

note: the onaction parameter s/b set last,
AFTER adding the listitems.


Dim cel, rng
.......
With .Controls.Add(Parameter:=8, Temporary:=True, _
Type:=msoControlDropdown)
.Caption = "Region"
With Worksheets("Control")
Set rng = .Range(.Cells(3, 2), .Cells(Rows.Count, 2).End(xlUp))
End With
For Each cel In rng
.AddItem cel.Value
Next
.ListIndex = 1
.OnAction = ThisWorkbook.Name & "!tbhandler"
End With



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Nigel wrote :

Hi keepItCool
That fixed it and gave me some insight how to handle parameters in the
actioncontrol. That is neat!

I have a supplementary questions...

Using this method I have added another control (dropdown box) and
filled the values from a worksheet list (that works), given it a
parameter of 8. How do I pass the value of the listindex from the
control to the tbhandler or do I need to use something else?

...........
With .Controls.Add(Parameter:=8, Type:=msoControlDropdown,
Temporary:=True)
.Caption = "Region"

Dim ctl As Worksheet
Set ctl = Sheets("Control")
Dim LrowTlist As Integer, xi As Integer
LrowTlist = ctl.Cells(Rows.Count, "B").End(xlUp).Row
.Style = msoButtonAutomatic
.OnAction = ThisWorkbook.Name & "!tbhandler"
For xi = 3 To LrowTlist
.AddItem ctl.Cells(xi, 2).Value
Next xi
.ListIndex = 1
End With
........





 
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
Toolbar problems AOU Excel Discussion (Misc queries) 1 April 25th 07 12:22 PM
Toolbar/Menu Bar Big Dave Excel Discussion (Misc queries) 2 January 17th 07 02:56 PM
Can't find menu toolbar Brian B Excel Discussion (Misc queries) 2 June 22nd 06 09:01 PM
Toolbar Problems Stefan_B Excel Programming 1 April 6th 05 11:05 AM
icon in menu toolbar roland Excel Programming 1 November 20th 03 01:29 PM


All times are GMT +1. The time now is 12:21 AM.

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

About Us

"It's about Microsoft Excel"