Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default how to create sub menu items in Excel?

Hi all,
I created a custom menu in Excel. I would like to create sub menu items for
one of the menu items. I get an error 'Object not supported by this method'.

I have copied the code below: any suggestions why the error pops up?

Thanks in advance for any pointers.

the code:

Private Sub Workbook_Open()

Dim obj As Object
Dim helpmenu As Object
Dim btnobj As Object
Dim SubMenuItem As Object

For Each obj In Application.CommandBars(1).Controls
If obj.Caption = "De&mo Tool" Then
obj.Delete
Exit For
End If
Next
Set obj = Application.CommandBars(1).Controls.Add(msoControl Popup)
obj.Caption = "De&mo Tool"

Set btnobj = obj.Controls.Add(msoControlButton)
btnobj.Caption = "&Save data to file"
btnobj.OnAction = ThisWorkbook.Name & "!store"
btnobj.FaceId = 600
Set btnobj = obj.Controls.Add(msoControlButton)
btnobj.Caption = "F&ilter"
btnobj.FaceId = 601
Set SubMenuItem = btnobj.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = "&Asia"
SubMenuItem.OnAction = "Macrofilterasia"
End Sub

With regards,
Josh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to create sub menu items in Excel?

You can't add a button to a button which is what you are trying to do.

Set btnobj = obj.Controls.Add(msoControlButton)
should probably be msoControlPopup

--
Regards,
Tom Ogilvy


"Joshua" wrote in message
...
Hi all,
I created a custom menu in Excel. I would like to create sub menu items

for
one of the menu items. I get an error 'Object not supported by this

method'.

I have copied the code below: any suggestions why the error pops up?

Thanks in advance for any pointers.

the code:

Private Sub Workbook_Open()

Dim obj As Object
Dim helpmenu As Object
Dim btnobj As Object
Dim SubMenuItem As Object

For Each obj In Application.CommandBars(1).Controls
If obj.Caption = "De&mo Tool" Then
obj.Delete
Exit For
End If
Next
Set obj = Application.CommandBars(1).Controls.Add(msoControl Popup)
obj.Caption = "De&mo Tool"

Set btnobj = obj.Controls.Add(msoControlButton)
btnobj.Caption = "&Save data to file"
btnobj.OnAction = ThisWorkbook.Name & "!store"
btnobj.FaceId = 600
Set btnobj = obj.Controls.Add(msoControlButton)
btnobj.Caption = "F&ilter"
btnobj.FaceId = 601
Set SubMenuItem = btnobj.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = "&Asia"
SubMenuItem.OnAction = "Macrofilterasia"
End Sub

With regards,
Josh



Reply
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
Excel 97 menu items Oldjay Excel Discussion (Misc queries) 4 March 5th 08 11:48 PM
2 adobe menu items in Excel Appie Excel Discussion (Misc queries) 0 May 18th 06 08:33 AM
Remove Excel Menu Items robbybobby New Users to Excel 1 February 23rd 06 11:41 PM
Create/Remove Custom Menu Items from Add-in Michael Malinsky[_2_] Excel Programming 8 April 9th 05 01:01 PM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM


All times are GMT +1. The time now is 10:12 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"