Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default problem with beforeclose event

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default problem with beforeclose event

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
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
ThisWorkBook BeforeClose Event Doug Glancy Excel Programming 0 July 29th 04 12:36 AM
ThisWorkBook BeforeClose Event David Adamson[_4_] Excel Programming 0 July 29th 04 12:32 AM
Workbook_Beforeclose vs BeforeClose Event Juan Pablo González Excel Programming 3 February 2nd 04 12:17 AM
Cancelling the BeforeClose Event Troy[_5_] Excel Programming 6 December 2nd 03 06:40 AM
BeforeClose event - Savings Mike[_40_] Excel Programming 3 September 24th 03 11:33 AM


All times are GMT +1. The time now is 04:53 PM.

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

About Us

"It's about Microsoft Excel"