|
|
|
|
|
|
Excel
|
Hiding Command Bars and other Excel Workbook Characteristics
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2003
|
Submitted by:
|
Paleo
|
Description:
|
This code hides Command Bars, Formula Bar and Headings. Also changes the application Caption.
|
Discussion:
|
Sometimes we create applications in Excel where we don't want the user to actually know he is working in Excel, then we want to hide some Excel characteristics. This is what this code does.
|
Code:
|
instructions for use
|
Private Sub Workbook_Activate()
Call Desliga
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Liga
End Sub
Private Sub Workbook_Deactivate()
Call Liga
End Sub
Private Sub Workbook_Open()
Call Desliga
End Sub
Sub Desliga()
Dim cbars As CommandBar
Application.ScreenUpdating = False
For Each cbars In Application.CommandBars
cbars.Enabled = False
Next
With ActiveWindow
.DisplayHeadings = False
.Zoom = 80
End With
With Application
.DisplayFormulaBar = False
.Caption = "Aplica??o do Carlos"
.ScreenUpdating = True
End With
End Sub
Sub Liga()
Dim cbars As CommandBar
Application.ScreenUpdating = False
ActiveWindow.Zoom = 100
For Each cbars In Application.CommandBars
cbars.Enabled = True
Next
ActiveWindow.DisplayHeadings = True
With Application
.DisplayFormulaBar = True
.Caption = "Microsoft Excel"
.ScreenUpdating = True
End With
End Sub
|
How to use:
|
- Copy the above code.
- Open any workbook.
- Press Alt + F11 to open the Visual Basic Editor (VBE).
- From the Menu, double click This_Workbook
- Paste the code into the right-hand code window, except Subs Liga and Desliga, these must be pasted at Module 1. (To create it select Insert -> New module)
- Close the VBE, save the file if desired.
- Close the workbook
|
Test the code:
|
- Open the workbook
|
Sample File:
|
HideAndShowCommandBars.zip 7.9KB
|
Approved by mdmackillop
|
This entry has been viewed 204 times.
|
|