Eliminating Toolbars,Sheet Tabs,Scroll Bars. etc.

  • Thread starter mtm4300 via OfficeKB.com
  • Start date
M

mtm4300 via OfficeKB.com

I am having trouble writing a macro to disable all toolbars. I also want to
turnoff the column and row headings as well as the sheet tabs and scroll bars.
And I would like to restore all of these when the program closes. I only want
the toolbars to be disabled during the program and I want the toolbars there
if I open another Excel file. Is this possible to do with a macro?
 
B

Bob Phillips

Option Explicit

Private mFormulaBar
Private mStatusbar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

With ActiveWindow
.DisplayHeadings = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With

Application.DisplayFormulaBar = mFormulaBar
Application.StatusBar = mStatusBar

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
mStatusBar = Application.StatusBar
Application.StatusBar = False
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
M

mtm4300 via OfficeKB.com

Thank you.

Bob said:
Option Explicit

Private mFormulaBar
Private mStatusbar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

With ActiveWindow
.DisplayHeadings = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With

Application.DisplayFormulaBar = mFormulaBar
Application.StatusBar = mStatusBar

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
mStatusBar = Application.StatusBar
Application.StatusBar = False
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
 

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