vba: Show Full Screen

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
826
Office Version
  1. 365
Platform
  1. Windows
Thanks for looking. My goal is to have a macro that will make the command bar hide and display the sheet in full screen.
Also I would like a macro to undo all the above, but this macro would need a password to be executed. Here is some code that I found im just not sure how to put it all together.


Code:
Application.DisplayFullScreen = True
 Application.CommandBars("Full Screen").Enabled = False
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try the codes below

Code:
Sub test()
    Application.DisplayFullScreen = True
    ' comment out  options below as needed
    Application.CommandBars("Full Screen").Enabled = False
    ActiveWindow.DisplayWorkbookTabs = False
    Application.DisplayStatusBar = False
    Application.DisplayDocumentActionTaskPane = False
    Application.CommandBars.ActiveMenuBar.Enabled = False
    With ActiveWindow
        .DisplayHorizontalScrollBar = False
        .DisplayVerticalScrollBar = False
        .DisplayHeadings = False
    End With
End Sub


Sub test2()
    Dim Pwrd As String
    Pwrd = InputBox("Enter your password:", "Password")
    If Pwrd = "abc" Then
        Application.WindowState = xlNormal
        Exit Sub
    Else
        MsgBox "Wrong password!", vbCritical, "Error"
        Exit Sub
    End If
End Sub
 
Upvote 0
Actually after playing around with it you are better off reversing the first macro

Code:
Sub test2()    Dim Pwrd As String
    Pwrd = InputBox("Enter your password:", "Password")
    If Pwrd = "abc" Then
         Application.DisplayFullScreen = False
    ' comment out  options below as needed
    Application.CommandBars("Full Screen").Enabled = True
    ActiveWindow.DisplayWorkbookTabs = True
    Application.DisplayStatusBar = True
    Application.CommandBars.ActiveMenuBar.Enabled = True
    With ActiveWindow
        .DisplayHorizontalScrollBar = True
        .DisplayVerticalScrollBar = True
        .DisplayHeadings = True
    End With
        Exit Sub
    Else
        MsgBox "Wrong password!", vbCritical, "Error"
        Exit Sub
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,043
Messages
6,128,470
Members
449,455
Latest member
jesski

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top