LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default command bars

Hello,

I tried the following code (I get it from somebody, don't remember wh
…) to hide the normally used commandbars when entering an applicatio
and reinstall the same used commandbars again when leaving the program
The hiding works fine, but when leaving the application, the followin
message comes:

"Runtime error 9, Index outside valid array."

Whats wrong with the code.

The code:

Public arrayCB As Variant

Private Sub Workbook_Open()

Dim myCB As CommandBar
Dim ii As Long

ReDim arrayCB(0)
For Each myCB In Application.CommandBars
If myCB.Visible Then
ReDim Preserve aryCBs(ii)
arrayCB(ii) = myCB.Name
myCB.Visible = False
ii = ii + 1
End If
Next myCB
Application.CommandBars("Worksheet Menu Bar").Visible = False

With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False
End With

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim ii As Long

For ii = LBound(arrayCB) To UBound(arrayCB)
Application.CommandBars(arrayCB(ii)).Visible = True
Next ii

End Sub


… thanks Sigg

--
Message posted from http://www.ExcelForum.com

 
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
programming command bars Little Elephant with Big Ears Excel Discussion (Misc queries) 3 January 15th 10 07:16 PM
Custom Command Bars barrowhill Excel Discussion (Misc queries) 1 March 29th 08 02:19 PM
Command Bars KneeDown2Up Excel Discussion (Misc queries) 4 January 16th 07 05:43 PM
help! How do I restore command bars? nrussell New Users to Excel 5 May 26th 05 08:19 PM
Attaching Command Bars to Add-IN Thomas Herr Excel Programming 3 April 5th 04 08:38 PM


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