Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Command Bar Woes

Hi, I asked this question last week without any response. I thought
I'd try again since we're implementing this system in several places
now throughout our operations. Here goes...

I have a several custom command bars, I want to show each always and
only with a specific worksheet in a specific workbook. Each command
bar is stored with its respective workbook.

In "This Workbook" macro area I have

Private Sub Workbook_Activate
Application.CommandBars("MyCommandBar").Visible = True
End Sub

Private Sub Workbook_Deactivate
Application.CommandBars("MyCommandBar").Visible = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("MyCommandBar").Delete
End Sub

(I also have visible true/false to activate and deactivate the sheet,
but that is not where I seem to be having trouble)

Upon closing the workbook I get an error message: "Invalid Procedure
Call or Argument" that goes to the workbook_deactivate code when I hit
"debug".

I think it gives priority to the beforeclose/delete command, then
can't hide the already deleted command bar, causing trouble for me.

In the meantime, I've commented out the "before_close" code so the
command bar is only ever hidden. But: as we get the system up and
running, more and more workbooks have their own custom command bars to
clutter things up. I'd rather not have the command bars from closed
workbooks available at all. Is there some sort of code that can tell
excel not to bother trying to hide the command bar if the deactivation
is due to closing the workbook?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Command Bar Woes

Since the commandbar will not exist when the Deactivate event fires after
the Before_Close event you should just skip over the error:

Private Sub Workbook_Deactivate
On Error Resume Next
Application.CommandBars("MyCommandBar").Visible = False
End Sub


--
Jim
wrote in message
oups.com...
| Hi, I asked this question last week without any response. I thought
| I'd try again since we're implementing this system in several places
| now throughout our operations. Here goes...
|
| I have a several custom command bars, I want to show each always and
| only with a specific worksheet in a specific workbook. Each command
| bar is stored with its respective workbook.
|
| In "This Workbook" macro area I have
|
| Private Sub Workbook_Activate
| Application.CommandBars("MyCommandBar").Visible = True
| End Sub
|
| Private Sub Workbook_Deactivate
| Application.CommandBars("MyCommandBar").Visible = False
| End Sub
|
| Private Sub Workbook_BeforeClose(Cancel As Boolean)
| Application.CommandBars("MyCommandBar").Delete
| End Sub
|
| (I also have visible true/false to activate and deactivate the sheet,
| but that is not where I seem to be having trouble)
|
| Upon closing the workbook I get an error message: "Invalid Procedure
| Call or Argument" that goes to the workbook_deactivate code when I hit
| "debug".
|
| I think it gives priority to the beforeclose/delete command, then
| can't hide the already deleted command bar, causing trouble for me.
|
| In the meantime, I've commented out the "before_close" code so the
| command bar is only ever hidden. But: as we get the system up and
| running, more and more workbooks have their own custom command bars to
| clutter things up. I'd rather not have the command bars from closed
| workbooks available at all. Is there some sort of code that can tell
| excel not to bother trying to hide the command bar if the deactivation
| is due to closing the workbook?
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Command Bar Woes

That seems simple enough. Thanks!

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
Calculation woes.... Brad Excel Programming 1 January 22nd 07 10:56 PM
More RGB Woes Zone Excel Programming 3 August 19th 06 06:40 PM
Hyperlink Woes - Please Help Randy Excel Worksheet Functions 1 June 27th 06 02:07 PM
For Each Next woes AZ Analog Excel Programming 4 May 23rd 05 08:53 PM
ActiveSheet woes Arkdog Excel Programming 2 April 2nd 04 02:32 PM


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