Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Anthony
 
Posts: n/a
Default VBA script help..Please !!!!

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Maybe it's as simple as changing this:

Cbar.Name < "log"
to
lcase(cbar.name) < "log"

When VBA compares text, it's case sensitive (unless you do something special).



Anthony wrote:

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!


--

Dave Peterson
  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

And this doesn't look correct, either:

Private Sub workbook_Beforeclose(Cancle As Boolean)

Maybe ....

Private Sub Workbook_BeforeClose(Cancel As Boolean)




Anthony wrote:

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!


--

Dave Peterson
  #4   Report Post  
Anthony
 
Posts: n/a
Default

'thanks Dave, will give it a try and see how I get on, one other question to
try and make this a bit easier for me.
If I recorded a macro to close all the toolbars etc that I wanted and to
show my worksheet exactly how I wanted it to look, how would I get this
'macro' to run on openeing the worksheet and then how to I get all the menus
to open again when it has been closed.
Also wher shud I place this code in the VB editor - in the 'Thisworkbook'
part?

thanks Dave and sorry for dumb questions but I'm a little novice at VB etc.

"Dave Peterson" wrote:

And this doesn't look correct, either:

Private Sub workbook_Beforeclose(Cancle As Boolean)

Maybe ....

Private Sub Workbook_BeforeClose(Cancel As Boolean)




Anthony wrote:

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!


--

Dave Peterson

  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

That kind of code (hide toolbars when you open a workbook) goes into the
ThisWorkbook module.

If you were hiding the toolbars based on the sheet in a workbook, you could have
the code in the worksheet module that should show this behavior.



Anthony wrote:

'thanks Dave, will give it a try and see how I get on, one other question to
try and make this a bit easier for me.
If I recorded a macro to close all the toolbars etc that I wanted and to
show my worksheet exactly how I wanted it to look, how would I get this
'macro' to run on openeing the worksheet and then how to I get all the menus
to open again when it has been closed.
Also wher shud I place this code in the VB editor - in the 'Thisworkbook'
part?

thanks Dave and sorry for dumb questions but I'm a little novice at VB etc.

"Dave Peterson" wrote:

And this doesn't look correct, either:

Private Sub workbook_Beforeclose(Cancle As Boolean)

Maybe ....

Private Sub Workbook_BeforeClose(Cancel As Boolean)




Anthony wrote:

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Anthony
 
Posts: n/a
Default

sorry Dave
but how can I get excel to perform this macro automaticaly once I open the
sheet ??
thanks again
Anthony

"Dave Peterson" wrote:

That kind of code (hide toolbars when you open a workbook) goes into the
ThisWorkbook module.

If you were hiding the toolbars based on the sheet in a workbook, you could have
the code in the worksheet module that should show this behavior.



Anthony wrote:

'thanks Dave, will give it a try and see how I get on, one other question to
try and make this a bit easier for me.
If I recorded a macro to close all the toolbars etc that I wanted and to
show my worksheet exactly how I wanted it to look, how would I get this
'macro' to run on openeing the worksheet and then how to I get all the menus
to open again when it has been closed.
Also wher shud I place this code in the VB editor - in the 'Thisworkbook'
part?

thanks Dave and sorry for dumb questions but I'm a little novice at VB etc.

"Dave Peterson" wrote:

And this doesn't look correct, either:

Private Sub workbook_Beforeclose(Cancle As Boolean)

Maybe ....

Private Sub Workbook_BeforeClose(Cancel As Boolean)




Anthony wrote:

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!

--

Dave Peterson


--

Dave Peterson

  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default

If you mean open the workbook, then excel will do it automatically*

* assumes that you have the code in ThisWorkbook and events are enabled and
macros are enabled.



Anthony wrote:

sorry Dave
but how can I get excel to perform this macro automaticaly once I open the
sheet ??
thanks again
Anthony

"Dave Peterson" wrote:

That kind of code (hide toolbars when you open a workbook) goes into the
ThisWorkbook module.

If you were hiding the toolbars based on the sheet in a workbook, you could have
the code in the worksheet module that should show this behavior.



Anthony wrote:

'thanks Dave, will give it a try and see how I get on, one other question to
try and make this a bit easier for me.
If I recorded a macro to close all the toolbars etc that I wanted and to
show my worksheet exactly how I wanted it to look, how would I get this
'macro' to run on openeing the worksheet and then how to I get all the menus
to open again when it has been closed.
Also wher shud I place this code in the VB editor - in the 'Thisworkbook'
part?

thanks Dave and sorry for dumb questions but I'm a little novice at VB etc.

"Dave Peterson" wrote:

And this doesn't look correct, either:

Private Sub workbook_Beforeclose(Cancle As Boolean)

Maybe ....

Private Sub Workbook_BeforeClose(Cancel As Boolean)




Anthony wrote:

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
VBA Script for copy and paste to save tamato43 Excel Discussion (Misc queries) 3 May 17th 05 09:22 PM
Using a VB Script for barcodes - new to this Jon Excel Discussion (Misc queries) 2 May 13th 05 03:42 PM
Read only password script box Joey041 Excel Discussion (Misc queries) 1 May 3rd 05 02:23 AM
Can somebody check my script?? Anthony Excel Discussion (Misc queries) 3 March 2nd 05 10:31 AM
Macro script error - pls help !! Anthony Excel Discussion (Misc queries) 3 February 28th 05 02:49 PM


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