Thread: Index Popup
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Index Popup

'Adds a new menu to menu bar
cbcCutomMenu.Caption = "My Menu"

Set cbcCutomMenu1 = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu1.Caption = "Apple"

With cbcCutomMenu1.Controls.Add(Type:=msoControlButton)
.Caption = "Apple1"
.OnAction = "Gotoapple1"
End With
With cbcCutomMenu1.Controls.Add(Type:=msoControlButton)
.Caption = "Apple2"
.OnAction = "Gotoapple2"
End With

'---------------
if Worksheets("Opening Cover").OleObject("CheckBox1").Object.Value then
cbcCutomMenu1.Enabled = False
End if
'--------------
Set cbcCutomMenu2 = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu2.Caption = "Orange"

With cbcCutomMenu2.Controls.Add(Type:=msoControlButton)
.Caption = "Orange1"
.OnAction = "Gotoorange1"
End With
With cbcCutomMenu2.Controls.Add(Type:=msoControlButton)
.Caption = "Orange2"
.OnAction = "Gotoorange2"
End With
End Sub

--
Regards,
Tom Ogilvy


"Newbeetle" wrote in message
...
Hi Tom,

Works a treat, as simple as it is I would have never got that, thank you
so
much.

I was thinking is there a way to make the sub menu's ie "Apple" Enabled
True
and False Dependant on a command check box which is located on
Sheets("Opening Cover")

Thanks again for the help, that custom menu works a treat.

"Tom Ogilvy" wrote:

'Adds a new menu to menu bar
cbcCutomMenu.Caption = "My Menu"

Set cbcCutomMenu1 = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu1.Caption = "Apple"

With cbcCutomMenu1.Controls.Add(Type:=msoControlButton)
.Caption = "Apple1"
.OnAction = "Gotoapple1"
End With
With cbcCutomMenu1.Controls.Add(Type:=msoControlButton)
.Caption = "Apple2"
.OnAction = "Gotoapple2"
End With

Set cbcCutomMenu2 = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu2.Caption = "Orange"

With cbcCutomMenu2.Controls.Add(Type:=msoControlButton)
.Caption = "Orange1"
.OnAction = "Gotoorange1"
End With
With cbcCutomMenu2.Controls.Add(Type:=msoControlButton)
.Caption = "Orange2"
.OnAction = "Gotoorange2"
End With
End Sub

--
Regards,
Tom Ogilvy

"Newbeetle" wrote:

Hi Tom,

Thanks for the links

I have managed to get half way, that is I have a menu called "MyMenu"
added
to the menu bar. On clicking this I have a sub menu heading of Apple
which
leads to sub sub menu headings of "Apple1 and Apple2" When these are
clicked
the macros run and take me to the page required.

'Adds a new menu to menu bar
cbcCutomMenu.Caption = "My Menu"

Set cbcCutomMenu = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
cbcCutomMenu.Caption = "Apple"

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Apple1"
.OnAction = "Gotoapple1"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Apple2"
.OnAction = "Gotoapple2"
End With
End Sub

This runs and works without any problems, so I haven't shown all the
other
elements of the code.

Ok what I'm stuck on is I want to have in the "my menu" the sub menu
Apple
and another sub menu called orange, I then want the orange to have sub
sub
menus of "Orange1 and Orange2" just like I have done for Apple.

I have tried a few ways but cant get this right, so any help would be
so
welcomed.

Thanks


"Tom Ogilvy" wrote:

Not unless you build your own custom popup menu.

http://support.microsoft.com/default...b;en-us;830502
How to customize menus and menu bars in Excel


http://support.microsoft.com/?id=159619
XL97: Sample Macros for Customizing Menus and Submenus

http://support.microsoft.com/?id=213550
XL2000: Sample Macros for Customizing Menus and Submenus


http://support.microsoft.com/default...b;en-us;166755
File Title: Customizing Menu Bars, Menus, and Menu Items in
Microsoft(R)
Excel 97
File Name: WE1183.EXE
File Size: 58041 bytes
File Date: 06/20/97
Keywords: kbfile kbappnote
Description: This Application Note can help you learn techniques for
writing
Visual Basic(R) for Applications code to customize menus in Microsoft
Excel
97. This Application Note contains code examples that you can use
with the
following elements: menu bars, menus, menu items, submenus, and
shortcut
menus.

--
Regards,
Tom Ogilvy



"Newbeetle" wrote:

Hi I use the code below to create a popup menu that shows unhidden
tabs in a
workbook so that you can navigate to them quickly.


Option Explicit
'to create index popup on menu when you right mouse click on screen
Sub IndexCode()
Application.CommandBars("workbook Tabs").ShowPopup
End Sub

Is it possible to modify so that it lists certain tab names only,
which then
if clicked have sub menus ie

on a right mouse click and then clicking sheet index I see tab
names

Car
Bed
House

Then on clicking one of the items I see

Car
Car 1
Car 2
Car 3

Hope that makes sense.