View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jean-Yves[_2_] Jean-Yves[_2_] is offline
external usenet poster
 
Posts: 253
Default How do I lock or close t.bars for a workbook?

Hi all

As I have option explicit (all varaiable have to be declared)
x as to be declared as well
Option Explicit

Public TBVis() As Boolean

Sub RemoveToolBars()
ReDim TBVis(Application.Toolbars.Count)
Dim x As Integer
For x = 1 To Application.Toolbars.Count
TBVis(x) = Application.Toolbars(x).Visible
Application.Toolbars(x).Visible = False
Next x
End Sub

Sub RestoreToolBars()
On Error Resume Next
Dim x As Integer
For x = 1 To Application.Toolbars.Count
Application.Toolbars(x).Visible = TBVis(x)
Next x
End Sub

Regards
JY
"Paulo Alexandre ( PT )" wrote
in message ...
Hi
For me worked almost fine, it missed one, I'm triyng to find why.
PP

"Mr.G" wrote:

J-Y

Thanks but doesn't work. Don't bombard me now.I'm still newbee with VB.
Your first line breaks it a statement on its own when I insert on WB
open.

Anymore help?

"Jean-Yves" wrote:

HI,
From Google

| Public TBVis() As Boolean
|
| Sub RemoveToolBars()
| ReDim TBVis(Application.Toolbars.Count)
| For x = 1 To Application.Toolbars.Count
| TBVis(x) = Application.Toolbars(x).Visible
| Application.Toolbars(x).Visible = False
| Next x
| End Sub
|
| Sub RestoreToolBars()
| On Error Resume Next
| For x = 1 To Application.Toolbars.Count
| Application.Toolbars(x).Visible = TBVis(x)
| Next x
| End Sub
|
Regards
JY
"Mr.G" wrote in message
...
I want to close the toolbars that is open in Excel when a certain book
is
opened. I don't have a problem closing all toolbars and opening all
again
when you exit book.

I want VB to select the open ones and replace on exit again.

Any help?