Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default delete toolbar on workbook close

I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it "New" (for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I would like the
second toolbar to be deleted when "New" is closed. My attempts to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default delete toolbar on workbook close

Try

Application.CommandBars("CommandBarName").Delete


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Papa Jonah" wrote in
message
...
I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it
"New" (for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I
would like the
second toolbar to be deleted when "New" is closed. My attempts
to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default delete toolbar on workbook close

Depends upon what the toolbar is called, but it would go in the BeforeClose
event, something along the lines of

Application.Commandbars("myToolbar").Delete

--

HTH

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


"Papa Jonah" wrote in message
...
I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it "New" (for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I would like

the
second toolbar to be deleted when "New" is closed. My attempts to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default delete toolbar on workbook close

I understand what line to use. Where I am struggling is where to put the
line. I have tried creating a new routine called workbook_beforeclose in
thisworkbook but that doesn't work. I have also tried creating a
workbook_deactivate routine. Either these are not the right options, they
don't belong in thisworkbook, or they require something more.

Thanks

"Bob Phillips" wrote:

Depends upon what the toolbar is called, but it would go in the BeforeClose
event, something along the lines of

Application.Commandbars("myToolbar").Delete

--

HTH

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


"Papa Jonah" wrote in message
...
I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it "New" (for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I would like

the
second toolbar to be deleted when "New" is closed. My attempts to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default delete toolbar on workbook close



--

HTH

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


"Papa Jonah" wrote in message
...
I understand what line to use. Where I am struggling is where to put the
line. I have tried creating a new routine called workbook_beforeclose in
thisworkbook but that doesn't work. I have also tried creating a
workbook_deactivate routine. Either these are not the right options, they
don't belong in thisworkbook, or they require something more.

Thanks

"Bob Phillips" wrote:

Depends upon what the toolbar is called, but it would go in the

BeforeClose
event, something along the lines of

Application.Commandbars("myToolbar").Delete

--

HTH

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


"Papa Jonah" wrote in message
...
I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it "New"

(for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I would

like
the
second toolbar to be deleted when "New" is closed. My attempts to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default delete toolbar on workbook close

In the Thisworkbook code module, select Workbook from the top left dropdown.
Select BeforeClose from the right dropdown. Then add the code into that
skeleton event.

PS Get rid of yours, you have clearly done it wrongly.

--

HTH

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


"Papa Jonah" wrote in message
...
I understand what line to use. Where I am struggling is where to put the
line. I have tried creating a new routine called workbook_beforeclose in
thisworkbook but that doesn't work. I have also tried creating a
workbook_deactivate routine. Either these are not the right options, they
don't belong in thisworkbook, or they require something more.

Thanks

"Bob Phillips" wrote:

Depends upon what the toolbar is called, but it would go in the

BeforeClose
event, something along the lines of

Application.Commandbars("myToolbar").Delete

--

HTH

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


"Papa Jonah" wrote in message
...
I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it "New"

(for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I would

like
the
second toolbar to be deleted when "New" is closed. My attempts to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default delete toolbar on workbook close

In the Thisworkbook code module, select Workbook from the top left dropdown.
Select BeforeClose from the right dropdown. Then add the code into that
skeleton event.

PS Get rid of yours, you have clearly done it wrongly.

--

HTH

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


"Papa Jonah" wrote in message
...
I understand what line to use. Where I am struggling is where to put the
line. I have tried creating a new routine called workbook_beforeclose in
thisworkbook but that doesn't work. I have also tried creating a
workbook_deactivate routine. Either these are not the right options, they
don't belong in thisworkbook, or they require something more.

Thanks

"Bob Phillips" wrote:

Depends upon what the toolbar is called, but it would go in the

BeforeClose
event, something along the lines of

Application.Commandbars("myToolbar").Delete

--

HTH

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


"Papa Jonah" wrote in message
...
I want to delete a toolbar when a workbook is closed.
I have two custom toolbars that I am using.
First a toolbar opens when I open a workbook.
When some macros are run, another workbook is created - call it "New"

(for
purpose of this explanation.
After a series of macros run, a second toolbar is created. I would

like
the
second toolbar to be deleted when "New" is closed. My attempts to use
workbook_beforeClose and workbook_deactivate are failing.

I would appreciate any help.
TIA






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
Delete Web Toolbar when Open A Hyperlink workbook T_Yuri[_2_] Excel Discussion (Misc queries) 4 August 5th 08 01:06 PM
Custom Toolbar Doesn't Close Muggs Excel Discussion (Misc queries) 1 July 30th 07 12:19 AM
Delete/Close Excel file that is kept OPEN Jafer New Users to Excel 0 April 15th 05 05:34 AM
Add a close icon to Excel's Toolbar SNiness Excel Discussion (Misc queries) 1 December 10th 04 06:18 PM
Close a the current workbook and load another specified workbook Adrian[_7_] Excel Programming 4 August 7th 04 05:29 PM


All times are GMT +1. The time now is 10:22 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"