ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding Parts of Excel (https://www.excelbanter.com/excel-programming/290836-hiding-parts-excel.html)

Neil[_14_]

Hiding Parts of Excel
 
I would like my spreadsheet to hide parts of excel when a user opens it. Ideally it would hide almost everything, scrollbar, status bar, formula bar, sheet tabs etc. Can this be done with code and what code would it be?

Rob van Gelder[_4_]

Hiding Parts of Excel
 
I've seen solutions which do it, with problems.

This example I've seen sometimes wasn't able to restore the settings, so
when the user loaded Excel they got a menu bar and nothing else. Helpdesk
calls galore.

It's probably possible to do it properly though.
I recommend that you resist fighting Excel and try to work with it. Most
users are comfortable with the interface and standard toolbars.


One way using FullScreen:

Sub test()
With Application
.DisplayFullScreen = True
.CommandBars("Full Screen").Visible = False
End With
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
End Sub


Here's another way (test destroys, test2 restores)
Sub test()
Dim cmd As CommandBar

With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False
.DisplayScrollBars = False
For Each cmd In .CommandBars
If cmd.Visible And Not cmd.Name =
..CommandBars.ActiveMenuBar.Name Then
cmd.Controls(1).Tag = "Restore Me"
cmd.Visible = False
End If
Next
End With

'stuff that you gets saved with the workbook
With ActiveWindow
.DisplayHeadings = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
.DisplayWorkbookTabs = False
End With
End Sub

Sub test2()
On Error Resume Next
Dim cmd As CommandBar
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
.DisplayScrollBars = True
For Each cmd In .CommandBars
If cmd.Controls(1).Tag = "Restore Me" Then
cmd.Controls(1).Tag = ""
cmd.Visible = True
End If
Next
End With
End Sub




--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Neil" wrote in message
...
I would like my spreadsheet to hide parts of excel when a user opens it.

Ideally it would hide almost everything, scrollbar, status bar, formula bar,
sheet tabs etc. Can this be done with code and what code would it be?



Neil[_14_]

Hiding Parts of Excel
 
Where do I put the code so that it starts when the spreadsheet is openned?

Rob van Gelder[_4_]

Hiding Parts of Excel
 
I suspect that you want to make Excel look like just any other application.

I strongly recommend that you do not hide parts of Excel for this purpose.
Don't fight Excel's interface. Work *with* it - the features are useful to
users.

Here's your answer:

Private Sub Workbook_Open()
'code here to hide Excel bits
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'code here to unhide Excel bits
End Sub

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Neil" wrote in message
...
Where do I put the code so that it starts when the spreadsheet is openned?





All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com