LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Toolbar Not Creation Problem

Hello,

I trying to create a toolbar with popups & buttons. I using the macro
below to:

1. Create the toolbar
2. Add Popup menus with buttons
3. Add more buttons to hte main toolbar

My macro will not all multiple buttons to the Popup menus. How can I
add multiple buttons the the popup menus without using several with
statements?

<MACRO CODE BEGIN

Rem ****BEGIN**** Command / Tool Bar ************
Function TBN() As Variant
'Tool Bar Name
TBN = "ToolBar Example Test"
End Function
Sub CreateOtherCommandBar()
'
Dim i As Variant, j As Variant
Dim cPopup(1 To 9)
Dim macs(1 To 9, 1 To 9), caps(1 To 9, 1 To 9), tips(1 To 9, 1 To 9)

'Main Toolbar Control Popup Menus
cPopup(1) = "Column Options"
cPopup(2) = "Row Options"
cPopup(3) = "Sort Options"

'Main & Sub Toolbar Buttons
'Column Options
macs(1, 1) = "CTB1"
macs(1, 2) = "CTB2"
macs(1, 3) = "CTB3"
'Row Options
macs(2, 1) = "CTB1"
macs(2, 2) = "CTB2"
'Sort Options
macs(3, 1) = "CTB1"
macs(3, 2) = "CTB1"
'Main Toolbar Button Macros
macs(4, 1) = "MTB1"
macs(4, 2) = "MTB2"

'Column Options
caps(1, 1) = "H/U Col"
caps(1, 2) = "I/D Col"
caps(1, 3) = "Move Col"
'Row options
caps(2, 1) = "H/U Row"
caps(2, 2) = "I/D Row"
'Sort Options
caps(3, 1) = "Sort Asc"
caps(3, 1) = "Sort Dsc"
'Main Toolbar Button Captions
caps(4, 1) = "MTB1"
caps(4, 2) = "MTB2"

'Column Tips
tips(1, 1) = "H/U Col"
tips(1, 2) = "I/D Col"
tips(1, 3) = "Move Col"
'Row Tips
tips(2, 1) = "H/U Col"
tips(2, 2) = "I/D Col"
tips(2, 3) = "Move Col"
'Sort tips
tips(3, 1) = "H/U Col"
tips(3, 2) = "I/D Col"
tips(3, 3) = "Move Col"
'Main Toolbar Button Tips
tips(4, 1) = "H/U Col"
tips(4, 2) = "I/D Col"
tips(4, 3) = "Move Col"


'Delete Toolbar
DeleteOtherCommandBar

'Create Toolbar
With Application.CommandBars.Add
.Name = TBN
.Visible = True
For i = LBound(caps, 1) To UBound(caps, 1)
For j = LBound(caps, 2) To UBound(caps, 2)
If caps(i, j) < "" Then

'Create Popup Menus
With .Controls.Add(Type:=msoControlPopup)
If j = i Then .Caption = cPopup(i)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & macs(i, j)
.cPopup(i).Caption = caps(i, j)
.cPopup(i).TooltipText = tips(i, j)
End With
End With

'Create Buttons
If i = 4 Then
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & macs(i, j)
.Caption = caps(i, j)
.TooltipText = tips(i, j)
.Style = msoButtonIconAndCaption
End With
End If
End If
Next j
Next i
End With
End Sub

Sub DeleteOtherCommandBar()
'Toolbar name is defined above in Function TBN _
& can be changed
On Error Resume Next
Application.CommandBars(TBN).Delete
On Error GoTo 0
End Sub

<MACRO CODE END

Thank you for your help,
jfcby
 
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
Need Opinion on Toolbar Creation surfbored Excel Programming 2 October 9th 06 10:19 PM
Problem with function creation terminator_ba Excel Programming 6 July 1st 06 05:17 AM
Formula Creation via Add-in problem Bill Schanks Excel Programming 1 February 10th 06 12:02 AM
Problem with chart creation daniel chen Excel Discussion (Misc queries) 2 January 8th 06 06:27 PM
clear clipboard after Add-ins Toolbar creation Kyoux Excel Programming 3 October 2nd 03 04:05 AM


All times are GMT +1. The time now is 05:47 PM.

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"