Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Finding a menu in a commandbar collection


Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2004, 10:49 AM
TomG TomG is offline
Freshman
 
Join Date: Jul 2003
Posts: 48
Default Finding a menu in a commandbar collection


Hi,

I found some code that will create a custom menu and the code is stored within a workbook. Once the workbook is opened it adds the menu to the main menu. See code below:

Code:
Public Sub AddCustomMenu() Dim cbWSMenuBar As CommandBar Dim muCustom As CommandBarControl Dim iHelpIndex As Integer Set cbWSMenuBar = Application.CommandBars("Worksheet Menu Bar") iHelpIndex = cbWSMenuBar.Controls("Help").Index Set muCustom = cbWSMenuBar.Controls.Add(Type:=msoControlPopup, Before:=iHelpIndex, _ Temporary:=False) With muCustom .Caption = "&Finance UK Tools" With .Controls.Add(Type:=msoControlButton) .Caption = "&Batch Email" .OnAction = "c:\Program Files\FinanceUKTools.xls!CreateBatchMail" End With With .Controls.Add(Type:=msoControlButton) .Caption = "&Download to Access" .OnAction = "c:\Program Files\FinanceUKTools.xls!ADOFromExcelToAccess" End With End With End Sub

The actual procedures it references are also stored in the same workbook, so when the workbook reopens it will create another menu. What I would like it to do is to check whether the commandbar already exists, I've put together the following code but I don't think I'm looking at the right object because it is going through the toolbars not the menus. Can somebody point me in the right direction.

Code:
Private Sub Workbook_Open() Dim c As CommandBar Dim bolfound As Boolean For Each c In Application.CommandBar If c.Name = "Finance UK Tools" Then bolfound = True End If Next If found <> True Then Call AddCustomMenu End If

Cheers
Tom
Reply With Quote
  #2  
Old 01-28-2004, 11:11 AM
TomG TomG is offline
Freshman
 
Join Date: Jul 2003
Posts: 48
Default

Please ignore my question, I've just found what I needed in the "Excel FAQ - Excel 101".

Cheers
Tom
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Windows own language Breezer Interface and Graphics 15 12-10-2002 08:15 AM
Creating a RPG Menu Class (need OOP advice) Virgo Game Programming 9 10-26-2002 02:52 PM
Few Questions dealing with pictures crazycheetah General 21 06-17-2002 11:08 PM
VB Menus John General 8 02-05-2002 09:31 AM
sequential files mickey2000 General 31 11-05-2001 03:19 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->