View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Creating submenus

Post the code and example data.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Alan M" wrote in message
...
Yes this code also operates from a level driven table.

The levels currently are from 1-3 inclusive. I have added level 4 entries

to
the column and need to amend the Select Case code to account for this and
generate the correct actions. ANy ideas pleae.....sorry to be a

nuisance...I
have only today to get this done!!!

"Bob Phillips" wrote:

Alan,

I have a table driven menu builder myself, and basically it will mean an
amount of re-work. You will need to add a column to show that this row

is
subordinate to the previous row, and show when it reverts back. I have a
level number, and then use recursive code to build it.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Alan M" wrote in message
...
Hi Bob,

Many thanks for your post...however, the code I am using is linked to

a
sheet in with the menu is built up from the contents of the cells.

There
are
58 rows in the sheet! To use your code would mean starting from

scratch.
Can
you advise how to add a third level of menu i.e a sub submenu using

the
Select Case code I have shown on my previous post.

"Bob Phillips" wrote:

Option Explicit

'If you put code in the appropriate workbook open event, and
'delete it in the close it will exist only for that workbook.

'Here is an example of a building a commandbar on the fly
'when you open a workbook. It adds a sub-menu to the Tools menu.

Private Sub Workbook_Open()
Dim oCb As CommandBar
Dim oCtl As CommandBarPopup
Dim oCtlBtn As CommandBarButton

On Error Resume Next
Set oCb = Application.CommandBars("Worksheet Menu Bar")
oCb.Controls("myButton").Delete
On Error GoTo 0

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlPopup, _
temporary:=True)
oCtl.Caption = "myButton"
With oCtl

With .Controls.Add(Type:=msoControlPopup)
.Caption = "mySubMenu"
With .Controls.Add(Type:=msoControlButton)
.Caption = "mySubMacroButton1"
.FaceId = 161
.OnAction = "mySubMacro1"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "mySubMacroButton2"
.FaceId = 161
.OnAction = "mySubMacro2"
End With
End With

Set oCtlBtn = .Controls.Add(Type:=msoControlButton)
oCtlBtn.Caption = "myMacroButton2"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro2"
End With
'etc.
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCb As CommandBar

Set oCb = Application.CommandBars("Worksheet Menu Bar")
oCb.Controls("Tools").Controls("myButton").Delete
End Sub

'To add this, go to the VB IDE (ALT-F11 from Excel), and in
'the explorer pane, select your workbook. Then select the
'ThisWorkbook object (it's in Microsoft Excel Objects which
'might need expanding). Double-click the ThisWorkbook and
'a code window will open up. Copy this code into there,
'changing the caption and action to suit.

'This is part of the workbook, and will only exist with the
'workbook, but will be available to anyone who opens the
'workbook.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Alan M" wrote in message
...

Hi I am using this example code to create a menu in my workbook.

I
would
like to amend it so that submenu levels appear. ie.

Wizards-
Wizard1
Wizard2
Wizard3-
Subwizard1
Subwizard2

etc

Can anyone provide a clue for this please?