VBA exit full screen

Solved
Anthelm Posted messages 202 Status Member -  
Anthelm Posted messages 202 Status Member -
Hello,

I put some formulas in a file to display Excel in full screen and without the menu bar.

The problem is that when I open another file, it seems that this configuration is retained. Is this normal?

Do I need to add a "normal" display in VBA when closing the file I created, would that be sufficient?

Configuration: Windows / Firefox 64.0

3 answers

  1. Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 784
     
    Hello,

    “I put a few formulas in a file to allow Excel to display in full screen and without the menu bar.” That's very surprising!!!

    What formulas are you using for that?
    --
    Best regards
    Patrice
    0
    1. Anthelm Posted messages 202 Status Member 1
       
      'On file open, go to the "Input" sheet
      Private Sub Workbook_Open()

      Sheets("Input").Select
      Range("C45").Value = 0
      Sheets("Input").Select
      Range("C45").Select
      ActiveWindow.Zoom = 75
      ActiveWindow.ScrollColumn = 1
      ActiveWindow.ScrollRow = 1
      Application.DisplayFullScreen = True
      Application.CommandBars("Formatting").Visible = False
      Application.CommandBars("Standard").Visible = False
      Application.CommandBars("Worksheet Menu Bar").Enabled = False
      ActiveWindow.DisplayWorkbookTabs = False
      End Sub
      0
    2. Anthelm Posted messages 202 Status Member 1
       
      It's a bit ugly, sorry... I will rewrite it a little better at some point...
      0
  2. Anthelm Posted messages 202 Status Member 1
     
    Yes, well, that was it.

    I added:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Application.DisplayFullScreen = False
    Application.CommandBars("Formatting").Visible = True
    Application.CommandBars("Standard").Visible = True
    Application.CommandBars("Worksheet Menu Bar").Enabled = True
    ActiveWindow.DisplayWorkbookTabs = True

    End Sub

    And I no longer have any issues.
    0
  3. Mike-31 Posted messages 18405 Registration date   Status Contributor Last intervention   5 147
     
    Good evening,

    can you simplify and add error handling for both opening and closing to prevent Excel from crashing

    Private Sub Workbook_Open()
    On Error Resume Next
    Sheets("Saisie").Select
    Sheets("Saisie").Range("C45").Value = 0
    ActiveWindow.Zoom = 75
    ActiveWindow.ScrollColumn = 1
    ActiveWindow.ScrollRow = 1
    Application.DisplayFullScreen = True 'hides the ribbon
    ActiveWindow.DisplayWorkbookTabs = False 'hides the tabs
    End Sub

    and on closing
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Application.DisplayFullScreen = False 'restores the Ribbon
    ActiveWindow.DisplayWorkbookTabs = True 'shows the tabs
    End Sub
    See you soon
    Mike-31

    I am responsible for what I say, not for what you understand...
    0
    1. Anthelm Posted messages 202 Status Member 1
       
      Good evening! Thank you for your reply!

      Does it give a different result from what I tinkered with, or is it the same thing but prettier? :)
      0