Forum Discussion
Dustion: How to turn OFF/ON Ribbon, formular bar etc ect ??
- Nov 06, 2022
Aargh - I should have seen that. It should be
Private Sub Workbook_BeforeClose(Cancel As Boolean) ActiveWindow.DisplayGridlines = True ...The event is BeforeClose, not Close, and DisplayGridlines is a window property, not an application property.
The Show Gridlines and Show Headings settings are stored in the workbook. Since you change them in the code, Excel sees the workbook as changed, even if you haven't modified any cells.
It's too much though - and I think the
Application.ExecuteExcel4Macroconfuses more than it clears up - so I'll drop that.
I now have this code:
Private Sub Workbook_Open()
markerObjecter
ActiveWindow.DisplayGridlines = False
Application.DisplayFormulaBar = False
ActiveWindow.DisplayHeadings = False
' Application.CommandBars.ExecuteMso "HideRibbon"
' Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",FALSE)"
nextPNR = ThisWorkbook.Sheets("NR-Ark").Range("A1")
End Sub
Private Sub Workbook_Close(Cancel As Boolean)
ActiveWindow.DisplayGridlines = True
Application.DisplayFormulaBar = True
ActiveWindow.DisplayHeadings = True
' Application.CommandBars.ExecuteMso "ShowRibbon"
' Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
End Sub
But still there is problem with the Formula bar - it turns OFF but not ON again !
AND
When closing the file it asks for SAVE or NOT - eventhough I did NOT change anything !
Is there a cure for that ?
Aargh - I should have seen that. It should be
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWindow.DisplayGridlines = True
...
The event is BeforeClose, not Close, and DisplayGridlines is a window property, not an application property.
The Show Gridlines and Show Headings settings are stored in the workbook. Since you change them in the code, Excel sees the workbook as changed, even if you haven't modified any cells.