Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2005, 04:46 PM
Registered User
 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default add menuitem in excel using VB

I want to add (and afterwords remove) a custom menu-item in excel, using Visual Basic (NOT IN EXCEL VBA!!!).
In the Excel-application I wrote a code for it, included in a .xls-file.

How can I write a code WITHOUT using an excisting .xls-file

Please surprice me with your answers...

Jan D.

 
Old December 25th, 2005, 03:34 AM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

First step: Goto Project>References and add the "Microsoft Office Object Libary x.x" and the "Microsoft Excel Library x.x", where x.x represents your current Microsoft Office version.

(mxlApp represents your Excel Application here, create your own variable)
Set customBar = mxlApp.CommandBars("Worksheet Menu Bar")
Set newmenu = customBar.Controls.Add(Type:=Office.msoControlPopu p, Temporary:=True)
newmenu.Caption = "&TEST"
'creates a submenu (this is like File, Edit, Tools, Windows)
Set ctrl1 = newmenu.Controls.Add(Office.msoControlButton)
ctrl1.Caption = "&Sub1"
ctrl1.OnAction = "module_to_run_when_clicked"
'ctrl1 is a control which can be seen when clicking on, for example File, ....). When clicked, the subroutine which is set at .Onaction will be called






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to control selected MenuItem programatically melania BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 9 November 13th, 2008 12:54 PM
How to make enable true for menuItem in C# akumarp2p C# 1 December 15th, 2006 05:32 AM
add menuitem in excel using VB jazzyJan Beginning VB 6 1 December 25th, 2005 03:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.