Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create submenu in menus 1

Status
Not open for further replies.

hermanlaksko

Programmer
Aug 26, 2001
941
DK
Is it possible to have a submenu in a menubar i.e. in the menupoint "Tools" one can select "Database utilities" and her one will get several submenu points i.e. "Compact and reapir database"

Is this posible in menus thet one self creates?

Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Drag the "NewMenu" to the location from customize dialog. You can see a divider like line appear in the menu.That is all.
or if you need a tutorial see


________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
Hi Zameer
Thx for your reply, but that part I know.
It was the next "step" I was looking for :-D

Thk for the URL tip, I will lok into that one.

Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
When you are creating a new menu from the Customize box, in the Commands tab last item is "NewMenu" that is with an arrow mark at the right side.
Try dragging that on to the menubar. Try keeping the mouse at the sides without releasing the mouse.

________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
Some code thingies?

I'm pretty sure I've stolen this off a book or the net, but I can't remember from where, so I don't know who to credit, I'm afraid. Only thing I know, is, I use too much time every time I'm trying to understand it;-)

Using late binding, so no references are needed. Relevant reference would be the Office <version> Object Library

The litterals used here, are:[tt]
10 msoControlPopup
1 msoCommandButton

Public Sub CreateCustomMenu()

Dim mnuHelp As Object
Dim mnuNew As Object
Dim mnuItem As Object
Dim mnuSubItem As Object

On Error Goto CreateCustomMenu_Err

' felete menu, if it alredy exists
Call RemoveCustomMenu

' find the Help menu (id 30010), to place this "in front"
Set mnuHelp = Application.CommandBars("Menu Bar").FindControl(id:=30010)
If (mnuHelp Is Nothing) Then
' no help menu - oups... add to end
Set mnuNew = Application.CommandBars("Menu Bar").Controls.Add( _
Type:=10, temporary:=True)
Else
' add in front of help menu
Set mnuNew = Application.CommandBars("Menu Bar").Controls.Add( _
Type:=10, temporary:=True, Before:=mnuHelp.Index)
End If
mnuNew.Caption = "&My Custom"

' Adding menu items
Set mnuItem = mnuNew.Controls.Add(Type:=1)
With mnuItem
.Caption = "&First entry"
.OnAction = "SomeSub_or_function"
End With
Set mnuItem = mnuNew.Controls.Add(Type:=1)
With mnuItem
.Caption = "Se&cond entry"
.OnAction = "SomeOtherSub_or_function"
End With
' One submenu
Set mnuItem = mnuNew.Controls.Add(Type:=10)
With mnuItem
.BeginGroup = True
.Caption = "SubMenu"
End With
' Adding menu items
Set mnuSubItem = mnuItem.Controls.Add(Type:=1)
With mnuSubItem
.Caption = "&First sub entry"
.OnAction = "SomeSub_Sub_or_function"
End With
Set mnuSubItem = mnuItem.Controls.Add(Type:=1)
With mnuSubItem
.Caption = "Se&cond sub entry"
.OnAction = "SomeOtherSub_Sub_or_function"
End With

CreateCustomMenu_Exit:
Set mnuHelp = Nothing
Set mnuNew = Nothing
set mnuItem = Nothing
Set mnuSubItem = Nothing
Exit Sub
CreateCustomMenu_Err:
MsgBox Err.Description
Resume CreateCustomMenu_Exit
End Sub

Sub RemoveCustomMenu()
On Error Resume Next
Application.CommandBars("Menu Bar").Controls("&My Custom").Delete
End Sub
[/tt]

Roy-Vidar
 
Zameer, That part I did not know THX! U are the star-tipper of my day :-D

Roy Thx for your effords I will look into your code and try to make it work in my direction thx!


Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top