How do I lock or close t.bars for a workbook?

G

Guest

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?
 
J

Jean-Yves

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
 
G

Guest

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?
 
J

Jean-Yves

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
 
G

Guest

Hi all

I don't know , it gives me a error.
Ambiguous name detected:RemoveToolBars

Maybe this is the problem.I do not have VB installed.I'm using VBE and VBA
in Excel.

Maybe someone has a different solution. I've written a small program and I
don't
want anyone to fiddle.I have locked the all that can be locked and that is
fine.
But now when the welcome note displays, it doesn't close the area in the
sheet on all CPU's the same. Sometimes only half of the area is closed.

Any help?
 
J

Jean-Yves

HI,
The error "ambiguous name detected" comes if the same name (ie
RemoveToolBars) is used mored than once to declare a sub.
Where is it located. Press the CTRL key + F, and sear the all project to
search for RemoveToolBars.
Where do you have code ?
Regards
JY
 
G

Guest

JY sorry went away for a while will look at it in a week or two and let you
know.

Thanx
G
 
G

Guest

Got it!!!!!!!!!!!
Dim c As CommandBar
For Each c In commandBars
c.Enabled=False
Next c

I'm sorry was suppose to say commandbars instead of toolbars.

Thanx
 
J

Jean-Yves

Glad you got it to work
Regards
JY

Mr.G said:
Got it!!!!!!!!!!!
Dim c As CommandBar
For Each c In commandBars
c.Enabled=False
Next c

I'm sorry was suppose to say commandbars instead of toolbars.

Thanx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top