ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_BeforeClose (https://www.excelbanter.com/excel-programming/321984-workbook_beforeclose.html)

PO

Workbook_BeforeClose
 
Hi!

I use the Workbook_Open() event to add a custom commandbar and a custom
commandbarcontrol.
I want to remove both commandbars when the user closes the workbook . I've
tried to use the Workbook_BeforeClose event, but that returns an error (see
code below) - 91:

Sub Workbook_BeforeClose
CommandBars(1).Controls("Tid&lista").Delete
CommandBars("Tidlista").Delete
End Sub

Any ideas?

TIA
PO



Bob Phillips[_6_]

Workbook_BeforeClose
 
Assuming that Menu is hanging off of Worksheet Menu Bar, this should work

Sub Workbook_BeforeClose
CommandBars(1).Controls("Tid&lista").Delete
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"PO" <po wrote in message ...
Hi!

I use the Workbook_Open() event to add a custom commandbar and a custom
commandbarcontrol.
I want to remove both commandbars when the user closes the workbook . I've
tried to use the Workbook_BeforeClose event, but that returns an error

(see
code below) - 91:

Sub Workbook_BeforeClose
CommandBars(1).Controls("Tid&lista").Delete
CommandBars("Tidlista").Delete
End Sub

Any ideas?

TIA
PO





Ron de Bruin

Workbook_BeforeClose
 
Hi PO

We don't see the code that create the bar so it is diffecult to give a answer but
you can find your answer here

http://support.microsoft.com/default...02&Product=xlw
How to customize menus and menu bars in Excel
http://support.microsoft.com/default...09&Product=xlw
XL2000: Sample Macros that Customize and Control Shortcut Menus
http://support.microsoft.com/default...50&Product=xlw
XL2000: Sample Macros for Customizing Menus and Submenus

http://support.microsoft.com/default...55&Product=xlw
XL97: WE1183: "Customizing Menu Bars, Menus, and Menu Items"
http://support.microsoft.com/default...19&Product=xlw
XL97: Sample Macros for Customizing Menus and Submenus
http://support.microsoft.com/default...78&Product=xlw
XL97: Sample Macros That Customize and Control Shortcut Menus

--
Regards Ron de Bruin
http://www.rondebruin.nl



"PO" <po wrote in message ...
Hi!

I use the Workbook_Open() event to add a custom commandbar and a custom
commandbarcontrol.
I want to remove both commandbars when the user closes the workbook . I've
tried to use the Workbook_BeforeClose event, but that returns an error (see
code below) - 91:

Sub Workbook_BeforeClose
CommandBars(1).Controls("Tid&lista").Delete
CommandBars("Tidlista").Delete
End Sub

Any ideas?

TIA
PO






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com