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

Hi all,

I am using custom command bars (a different one for each sheet in my workbook)

my question is, how do i get it to 'deactivate' when the workbook is changed?

i'm assuming the code would go in ThisWorkbook under
Private Sub Workbook_Deactivate()

End Sub

but i'm lost as to how to 1) deactivate the command bar and 2) know which
one to deactivate.

my bars are defined like this
Sheet 1:
Set cb = Application.CommandBars.Add("MyBar1", msoBarFloating)
Sheet 2:
Set cb = Application.CommandBars.Add("MyBar2", msoBarFloating)
etc

any help?

tia!

J
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Command Bar & Workbook Deactivate

Gixxer_J_97 wrote:
Hi all,

I am using custom command bars (a different one for each sheet in my workbook)

my question is, how do i get it to 'deactivate' when the workbook is changed?

i'm assuming the code would go in ThisWorkbook under
Private Sub Workbook_Deactivate()

End Sub

but i'm lost as to how to 1) deactivate the command bar and 2) know which
one to deactivate.

my bars are defined like this
Sheet 1:
Set cb = Application.CommandBars.Add("MyBar1", msoBarFloating)
Sheet 2:
Set cb = Application.CommandBars.Add("MyBar2", msoBarFloating)
etc

any help?

tia!

J

------------------

Below is a snippet of code I use to kill a custom tool bar. It is called from
the same Workbook_Deactivate() routine that you are using.

Sub DeleteToolBar()
Const TbarName As String = "YourToolbarName"
On Error Resume Next
CommandBars(TbarName).Delete
On Error GoTo 0
End Sub

Good luck...

Bill
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Command Bar & Workbook Deactivate

Thanks Bill,

After a few tweaks i ended up with:

Private Sub Workbook_Deactivate()
On Error Resume Next
Application.CommandBars(activeMenu).Visible = False
On Error GoTo 0
End Sub

Private Sub workbook_activate()
On Error Resume Next
Application.CommandBars(activeMenu).Visible = True
On Error GoTo 0
End Sub
thanks! =)

which hides/unhides the menu as you switch back and forth between workbooks.

J

"Bill Martin" wrote:

Gixxer_J_97 wrote:
Hi all,

I am using custom command bars (a different one for each sheet in my workbook)

my question is, how do i get it to 'deactivate' when the workbook is changed?

i'm assuming the code would go in ThisWorkbook under
Private Sub Workbook_Deactivate()

End Sub

but i'm lost as to how to 1) deactivate the command bar and 2) know which
one to deactivate.

my bars are defined like this
Sheet 1:
Set cb = Application.CommandBars.Add("MyBar1", msoBarFloating)
Sheet 2:
Set cb = Application.CommandBars.Add("MyBar2", msoBarFloating)
etc

any help?

tia!

J

------------------

Below is a snippet of code I use to kill a custom tool bar. It is called from
the same Workbook_Deactivate() routine that you are using.

Sub DeleteToolBar()
Const TbarName As String = "YourToolbarName"
On Error Resume Next
CommandBars(TbarName).Delete
On Error GoTo 0
End Sub

Good luck...

Bill

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Command Bar & Workbook Deactivate

Congrats on figuring it out!

Bill
-------------------------
Gixxer_J_97 wrote:
Thanks Bill,

After a few tweaks i ended up with:

Private Sub Workbook_Deactivate()
On Error Resume Next
Application.CommandBars(activeMenu).Visible = False
On Error GoTo 0
End Sub

Private Sub workbook_activate()
On Error Resume Next
Application.CommandBars(activeMenu).Visible = True
On Error GoTo 0
End Sub
thanks! =)

which hides/unhides the menu as you switch back and forth between workbooks.

J

"Bill Martin" wrote:


Gixxer_J_97 wrote:

Hi all,

I am using custom command bars (a different one for each sheet in my workbook)

my question is, how do i get it to 'deactivate' when the workbook is changed?

i'm assuming the code would go in ThisWorkbook under
Private Sub Workbook_Deactivate()

End Sub

but i'm lost as to how to 1) deactivate the command bar and 2) know which
one to deactivate.

my bars are defined like this
Sheet 1:
Set cb = Application.CommandBars.Add("MyBar1", msoBarFloating)
Sheet 2:
Set cb = Application.CommandBars.Add("MyBar2", msoBarFloating)
etc

any help?

tia!

J


------------------

Below is a snippet of code I use to kill a custom tool bar. It is called from
the same Workbook_Deactivate() routine that you are using.

Sub DeleteToolBar()
Const TbarName As String = "YourToolbarName"
On Error Resume Next
CommandBars(TbarName).Delete
On Error GoTo 0
End Sub

Good luck...

Bill

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
"Shared Workbook" seems to deactivate features like macros Steve Excel Discussion (Misc queries) 3 May 1st 07 05:11 PM
Workbook Deactivate incjourn[_4_] Excel Programming 1 September 14th 04 02:51 PM
Workbook Deactivate Event TerryF[_2_] Excel Programming 1 January 6th 04 01:16 AM
UserForms to deactivate workbook Vasant Nanavati Excel Programming 0 December 20th 03 05:09 AM
Disable a command from with in a workbook Tony Pizza Excel Programming 0 July 22nd 03 12:42 AM


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

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"