Hi,
I need a code which hide Ribbon, Gridlines, Heading and FormulaBar using VBA.
Thanx in Advance.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Hi,
I need a code which hide Ribbon, Gridlines, Heading and FormulaBar using VBA.
Thanx in Advance.
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Last edited by DocAElstein; 06-12-2023 at 05:51 PM.
Hi,
Try
and call the routineCode:Sub ToggleProperties(ByVal ShowRowColHeads As Boolean, _ ByVal ShowSheetTab As Boolean, _ ByVal ShowGridLines As Boolean, _ ByVal DisplayFBar As Boolean, _ ByVal DisplayRibbon As Boolean, _ ParamArray ShtNames() As Variant) If Not IsMissing(ShtNames) Then ThisWorkbook.Worksheets(ShtNames).Select ActiveWindow.DisplayHeadings = ShowRowColHeads ActiveWindow.DisplayWorkbookTabs = ShowSheetTab ActiveWindow.DisplayGridlines = ShowGridLines Application.DisplayFormulaBar = DisplayFBar Application.SendKeys ("^{F1}") ThisWorkbook.Worksheets(ShtNames(0)).Select End If End Sub
Note: Minimising Ribbon command toggles the current status of the Ribbon. If the Ribbon is minimised, it'll maximise and vice versa.Code:Sub kTest() ToggleProperties False, False, False, False, False, "Sheet1", "Sheet2" End Sub
Cheers !
Excel Range to BBCode Table
Use Social Networking Tools If You Like the Answers !
Message to Cross Posters
@ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)
You can replace the command to toggle ribbon visibility
with thisCode:Application.SendKeys ("^{F1}")
Code:Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon""," & DisplayRibbon & ")"
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
missing from sample code....
"DisplayRibbon" does not change anything
there are five parameters provided to set values:
please advise of corrected code sampleCode:ShowRowColHeads As Boolean, ShowSheetTab As Boolean, _ ShowGridLines As Boolean, _ DisplayFBar As Boolean, _ DisplayRibbon As Boolean only four are utilized ActiveWindow.DisplayHeadings = ShowRowColHeads ActiveWindow.DisplayWorkbookTabs = ShowSheetTab ActiveWindow.DisplayGridlines = ShowGridLines Application.DisplayFormulaBar = DisplayFBar
FYI: thread rating of "BAD" due to incomplete sample code... and worst of all misses the question of how to manipulate "ribbon"
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
Last edited by DocAElstein; 06-11-2023 at 01:15 PM.
It is easily understood from my post above that you should REPLACE one line with another.
Code:Sub ToggleProperties(ByVal ShowRowColHeads As Boolean, _ ByVal ShowSheetTab As Boolean, _ ByVal ShowGridLines As Boolean, _ ByVal DisplayFBar As Boolean, _ ByVal DisplayRibbon As Boolean, _ ParamArray ShtNames() As Variant) If Not IsMissing(ShtNames) Then ThisWorkbook.Worksheets(ShtNames).Select ActiveWindow.DisplayHeadings = ShowRowColHeads ActiveWindow.DisplayWorkbookTabs = ShowSheetTab ActiveWindow.DisplayGridlines = ShowGridLines Application.DisplayFormulaBar = DisplayFBar Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon""," & DisplayRibbon & ")" ThisWorkbook.Worksheets(ShtNames(0)).Select End If End Sub
A dream is not something you see when you are asleep, but something you strive for when you are awake.
It's usually a bad idea to say that something can't be done.
The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve
Join us at Facebook
I think to hide ribbon. Best to switch the workbook in full view mode.
I hope it is tricky..
Here is a non sendkeys method to minimize/maximize Ribbon (works XL 2010)
Code:Option Explicit Sub ToggleProperties(ByVal ShowRowColHeads As Boolean, _ ByVal ShowSheetTab As Boolean, _ ByVal ShowGridLines As Boolean, _ ByVal DisplayFBar As Boolean, _ ByVal DisplayRibbon As Boolean, _ ParamArray ShtNames() As Variant) Const RibbonHeightSafeSide = 100 'adjust this if necessary If Not IsMissing(ShtNames) Then ThisWorkbook.Worksheets(ShtNames).Select ActiveWindow.DisplayHeadings = ShowRowColHeads ActiveWindow.DisplayWorkbookTabs = ShowSheetTab ActiveWindow.DisplayGridlines = ShowGridLines Application.DisplayFormulaBar = DisplayFBar If DisplayRibbon Then If Application.CommandBars.Item("Ribbon").Height < RibbonHeightSafeSide Then Application.CommandBars.ExecuteMso "MinimizeRibbon" 'or use send keys 'Application.SendKeys ("^{F1}") DoEvents End If ElseIf Application.CommandBars.Item("Ribbon").Height > RibbonHeightSafeSide Then Application.CommandBars.ExecuteMso "MinimizeRibbon" 'or use send keys 'Application.SendKeys ("^{F1}") DoEvents End If ThisWorkbook.Worksheets(ShtNames(0)).Select End If End Sub
Cheers !
Excel Range to BBCode Table
Use Social Networking Tools If You Like the Answers !
Message to Cross Posters
@ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)
To avod 'select':
Code:If Not IsMissing(c00) Then With Windows(c00) .DisplayHeadings = Not .DisplayHeadings .DisplayWorkbookTabs = Not .DisplayWorkbookTabs .DisplayGridlines = Not .DisplayGridlines End With Application.DisplayFormulaBar = Not Application.DisplayFormulaBar End If
The 'Select' is necessary otherwise the arguments will work only for the first worksheet, if we pass more than 1 worksheet.
Cheers !
Excel Range to BBCode Table
Use Social Networking Tools If You Like the Answers !
Message to Cross Posters
@ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)
Bookmarks