Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default add a menu bar when document opens

Hoe do I get a macro to auto open and auto remove? I have
the macros below that I want to add a menu item when I
open the workbook its in and remove it when I close the
workbook. I have been playing with it and can't get it to
work.

Can anyone help?



Todd







Sub MenuBar_Item_Item()
Dim MenuItem As CommandBarControl
MenuBar_Item_Item_Delete

Set MenuItem = Application.CommandBars.FindControl(,
30007) 'Tools menu
If MenuItem Is Nothing Then Exit Sub
With MenuItem.Controls.Add(msoControlButton, 1, , ,
True)
.Caption = "&OpenSupportingDocs"
.OnAction = ThisWorkbook.Name
& "OpenSupportingDocs"
.BeginGroup = True
.Tag = "MenuItemTag"
End With
Set MenuItem = Nothing
End Sub

Sub MenuBar_Item_Item_Delete()
Dim MenuItem As CommandBarControl
Set MenuItem = Application.CommandBars.FindControl
(Tag:="MenuItemTag")
If Not MenuItem Is Nothing Then
MenuItem.Delete
End If
Set MenuItem = Nothing
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default add a menu bar when document opens

This file might be a help:
http://www.bygsoftware.com/examples/...tiveWbDemo.zip

It's in the "Menu Routines" section on page:
http://www.bygsoftware.com/examples/examples.htm

It contains VBA code that will activate a menu only when the workbook it is
in is active.
The code is open and commented.

--

Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"


"Todd" wrote in message
...
Hoe do I get a macro to auto open and auto remove? I have
the macros below that I want to add a menu item when I
open the workbook its in and remove it when I close the
workbook. I have been playing with it and can't get it to
work.

Can anyone help?



Todd







Sub MenuBar_Item_Item()
Dim MenuItem As CommandBarControl
MenuBar_Item_Item_Delete

Set MenuItem = Application.CommandBars.FindControl(,
30007) 'Tools menu
If MenuItem Is Nothing Then Exit Sub
With MenuItem.Controls.Add(msoControlButton, 1, , ,
True)
.Caption = "&OpenSupportingDocs"
.OnAction = ThisWorkbook.Name
& "OpenSupportingDocs"
.BeginGroup = True
.Tag = "MenuItemTag"
End With
Set MenuItem = Nothing
End Sub

Sub MenuBar_Item_Item_Delete()
Dim MenuItem As CommandBarControl
Set MenuItem = Application.CommandBars.FindControl
(Tag:="MenuItemTag")
If Not MenuItem Is Nothing Then
MenuItem.Delete
End If
Set MenuItem = Nothing
End Sub



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
Alt E no longer opens Edit menu simonc Excel Discussion (Misc queries) 4 September 8th 08 03:52 PM
Alt+E No Longer Opens Edit menu dee Excel Discussion (Misc queries) 5 July 19th 07 01:08 AM
Excel opens, but document doesn't Stevie Setting up and Configuration of Excel 1 September 7th 06 12:59 PM
Excel Document opens twice Mindie Setting up and Configuration of Excel 1 May 30th 06 06:34 PM
My document opens but all I see is a grey screen. stuck Excel Discussion (Misc queries) 1 January 25th 05 06:43 PM


All times are GMT +1. The time now is 08:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"