I have a macro that hides the ribbon, headings, tabs, scrollbar, etc. and a macro that unhides everything again. However, I'm having trouble with showing the Ribbon again. The following line does not work for me:
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
I've tried running the command in a separate macro, but I can't bring back the Ribbon again. I can't press CTRL + F1 and in the options menu the Ribbon section is completely empty. The only way to bring it back, is to open a new document, that seems to rest it. Does anyone know what could be wrong?
Sub UI()
Worksheets("MAIN").Activate
With ActiveWindow
.DisplayHeadings = False
.DisplayWorkbookTabs = False
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
With Application
.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
.DisplayStatusBar = False
.DisplayFormulaBar = False
End With
End Sub
Here is the macro that unhides everything
Sub UI_Reset()
Worksheets("MAIN").Activate
With ActiveWindow
.DisplayHeadings = True
.DisplayWorkbookTabs = True
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With
With Application
.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
.DisplayStatusBar = True
.DisplayFormulaBar = True
End With
End Sub
Related
so I tried the solutions here Excel ScreenUpdating False and still flickering screen but nth worked , im wondering if I should put the screen update in the fucntion I call
Note that the function i call is gonna call another that'll parse data in the sheet once button 2 is clicked,Here's the code I did so far
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
ButtonOneClick = False
Call SheetName
If ButtonOneClick Then
Me.CommandButton2.Visible = True
Else
Me.CommandButton2.Visible = False
End If
Application.ScreenUpdating = True
End Sub
Background: This project is gets loaded into full screen maximized.To make it look good I took out the tabs, formula bar, headers and status bar. I created my own buttons customized from shapes. These do have some very attractive colors and 3D views and I am wondering it is my code or the shapes that cause it to load slowly. When I Click a button to change pages is when this happens. Initially I had the button macros simply changing the pages but I thought it was slow because i was using select code. worksheet.Activate and worksheets.range.select. And the code was in the worksheet private sub under the Activate event. Then I took the code from there removed the select criteria and it almost feels slower. Is there anything I can do to pick up speed? Thank you.
This Example shows how the buttons are positioned up top of each worksheet. There are 10 sheets with these buttons which are shapes.
Example of 1 worksheet with Navigation Buttons on top
Here is the code im using now. This code is in public subs for a general module.
Sub StartPg()
'ChangePagesmacro
With wsStart.Application 'initiate page loading
.Calculation = xlCalculationManual 'turn off calculations
.ScreenUpdating = False 'turn off screen updates
.EnableEvents = False 'disable events
.Goto Reference:=wsStart.Range("A4"), Scroll:=True 'page starting point
With .ActiveWindow
If .FreezePanes Then .FreezePanes = False 'unfreeze panes to remove any jam up`enter code here`
.SplitColumn = 0 'unsplit column to free up screen
.SplitRow = 0 'unsplit row to free up screen
.WindowState = xlMaximized 'maximize window
.DisplayHeadings = False 'turn of page headings
.DisplayFormulas = False ' hide formula bar
.DisplayWorkbookTabs = False 'hide page tabs
.DisplayGridlines = False 'hide gridlines
.DisplayHorizontalScrollBar = True 'show scrollbar
.DisplayVerticalScrollBar = True 'show scrollbar
.Zoom = 81 'zoom and area
.ScrollColumn = 1 'scroll to top
.ScrollRow = 1 'scroll to left
.SplitColumn = 0 'split colum to be frozen
.SplitRow = 3 'split row to be frozen
.FreezePanes = True 'freeze panes
End With
End With
With wsStart
.ScrollArea = "SAStart" 'set user scroll area
With .Application
.Calculation = xlCalculationAutomatic 'turn on calculations
.ScreenUpdating = True ' turn on screen updates
.EnableEvents = True ' turn on events
.DisplayFormulaBar = False 'No formula bar
.DisplayStatusBar = False 'No status bar
.DisplayFullScreen = True ' show full screen
End With
End With
End Sub
I have Userform with buttons that are connected to codes. Why buttons keeps being pressed after code has been completed? Is there any way to release them?
Button looks like this after clicking on it:
Button code:
Private Sub ToggleButton2_Click()
ThisWorkbook.Worksheets("Price calculation").Activate
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Price calculation").Unprotect Password:="123"
Range("1867:1979").EntireRow.Hidden = False
ActiveSheet.Shapes("Rectangle: Rounded Corners 76").Visible = False
ActiveSheet.Shapes("Rectangle: Rounded Corners 244").Visible = True
ActiveWindow.ScrollRow = 1867
ThisWorkbook.Sheets("Price calculation").Protect Password:="123"
Application.ScreenUpdating = True
End Sub
You're using a toggle button. These toggle, unsurprisingly. I reckon you are looking to use a CommandButton instead.
In the toolbox browse for the CommandButton control Replace the ToggleButton with the newly added CommandButton. Then, edit the code for your togglebutton and replace it with:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
With ThisWorkbook.Sheets("Price calculation")
.Activate
.Unprotect Password:="123"
.Range("1867:1979").EntireRow.Hidden = False
.Shapes("Rectangle: Rounded Corners 76").Visible = False
.Shapes("Rectangle: Rounded Corners 244").Visible = True
ActiveWindow.ScrollRow = 1867 'Is this necessary? It scrolls to a specific hard-coded row
.Protect Password:="123"
End With
Application.ScreenUpdating = True
End Sub
I have a workbook that is designed to essentially operate as a standalone application. All sheets are protected, the individual excel tabs are hidden, and the top excel ribbon is hidden as well for the entire workbook.
The following VBA code performs the above procedures and is applied to every sheet within the workbook.
Sub masque()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayWorkbookTabs = False
Application.DisplayFullScreen = True
Application.DisplayStatusBar = Not Application.DisplayStatusBar
Application.WindowState = xlMaximized
ActiveWindow.WindowState = xlMaximized
Application.DisplayFormulaBar = False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
I want to use the following code as a button to override the prior code in order for an individual to easily switch between an "editor" mode and "user mode"
Sub masteredit()
Application.ScreenUpdating = False
ActiveWindow.View = xlNormalView
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayGridlines = False
ActiveWindow.DisplayWorkbookTabs = False
Application.DisplayStatusBar = False
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayVerticalScrollBar = True
ActiveWindow.DisplayWorkbookTabs = True
Application.DisplayFullScreen = False
Application.DisplayFormulaBar = True
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
Application.ScreenUpdating = True
What is a good way to accomplish this?
well, you could have a predermined type of user, for example, by default the app will be for user_mode. So you use a special sub called auto_open(), that will be run each time you open the workbook. So we have
sub auto_open()
call masque
end sub
And you can add buttons whenever you want to change between editor mode and user mode. You can put sub auto_open() in any module you want, because it is detected as special by Vba
Solved the issue.
I forgot I had the following code on every sheet in the workbook.
Sub Worksheet_Open()
Call masque
End Sub
Sub Worksheet_Activate()
Application.ScreenUpdating = False
Call masque
Application.ScreenUpdating = True
End Sub
Therefore, any time I tried to navigate to a different sheet, the masque would be applied.
To solve my issue, I removed the prior code from every page. I then added a checkbox on my "Home" page that used the following code.
Sub Worksheet_Open()
Call masque
End Sub
Sub Worksheet_Activate()
Application.ScreenUpdating = False
Call masque
Application.ScreenUpdating = True
End Sub
This way, when you open up the workbook the masque is automatically applied. However when you click the checkbox you enter editor mode and the masteredit sub is applied. And when it is unchecked, the masque is once again applied.
I am looking to disable zoom slider in excel worksheet. I have looked around but couldn't find a solution to it. There are some solutions pointing to setting the zoom to a defined value but none of them caters to disabling the zoom option itself.
Any help would be much appreciated.
I am adding the code I have put in ThisWorkbook to disable most of the visible option on worksheet.
Private Sub Workbook_Activate()
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Deactivate()
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
Application.ScreenUpdating = True
ActiveWindow.DisplayWorkbookTabs = True
End Sub
Private Sub Workbook_Open()
Application.ScreenUpdating = False
'Hide list of sheets
Call hide_sheets
Windows(1).WindowState = xlMaximized
ActiveWindow.DisplayGridlines = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.Zoom = 100
'Lock cells in the UI sheet
ThisWorkbook.Sheets("UI").ScrollArea = "A1:t46"
'Hide scroll bar
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
Application.ScreenUpdating = True
welcomeScreen.Show 0
End Sub
Some screen shots of the problem I am facing. I am currently using some makeshift arrangement by loading the maximized version userform on workbook opening. So the slider is hidden.
There doesn't appear to be a way to disable zoom completely or specifically the slider after looking around. If you're main mission is to avoid someone clicking on the zoom slider I would probably go with hiding the statusbar all together.
Application.DisplayStatusBar = False
To hide the zoom slider alone you can do so by editing the registry key
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Excel\StatusBar
by setting ZoomSlider value to 0
Anyway, i don't think this can be achieved using VBA even with SaveSetting.
You can try write a .reg file to change the target key and VBA-load it. I'm not sure if this can be done but even if it works the user will still to have click Yes in a system prompt to allow the key to be loaded into registry.
And even when the user click Yes to allow the .reg file to load and change the registry key, Excel status bar doesn't refresh to show/hide the ZoomSlider, until Excel is restarted.
In short, hiding zoom slider alone using VBA doesn't seem to be achievable.