Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
If I run the line below in the immediates window it works. CommandBars("standard").Controls.Item(5).Delete It deletes the fifth control on my toolbar. Yet it gives me an error when its run on the Before close event where I need it for my Excel add-in. Private Sub Workbook_BeforeClose(Cancel As Boolean) CommandBars("standard").Controls.Item(5).Delete End Sub This gives me an error and I can't figure out why. This is the error: Runtime error 91 Object variable or With Block variable not set If I make this an Auto_Close macro this line of code works. something about the before close event of the workbook makes it not work! Any Ideas? Thanks in advance Gordon |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Gordon,
For some reason adding "Application" makes it work for me: Application.CommandBars("Standard").Controls.Item( 5).Delete hth, Doug Glancy "Gordon" wrote in message ... Hi, If I run the line below in the immediates window it works. CommandBars("standard").Controls.Item(5).Delete It deletes the fifth control on my toolbar. Yet it gives me an error when its run on the Before close event where I need it for my Excel add-in. Private Sub Workbook_BeforeClose(Cancel As Boolean) CommandBars("standard").Controls.Item(5).Delete End Sub This gives me an error and I can't figure out why. This is the error: Runtime error 91 Object variable or With Block variable not set If I make this an Auto_Close macro this line of code works. something about the before close event of the workbook makes it not work! Any Ideas? Thanks in advance Gordon |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ThisWorkBook BeforeClose Event | Excel Programming | |||
ThisWorkBook BeforeClose Event | Excel Programming | |||
Workbook_Beforeclose vs BeforeClose Event | Excel Programming | |||
Cancelling the BeforeClose Event | Excel Programming | |||
BeforeClose event - Savings | Excel Programming |