+ Reply to Thread
Results 1 to 6 of 6

Hide ribbon/formula bar for this workbook only

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Hide ribbon/formula bar for this workbook only

    Hello!

    I'm trying to create some vba code that will always make the ribbon and formula bar hidden from the user for this workbook only.

    I have put the code in the workbook activate/deactivate events in the ThisWorkbook module but 1. I'm getting a runtime error 'Object variable or With block variable not set' for my ribbon line (even though this line works fine as it's own sub in a different worksheet module). 2. Even if I take this line out to focus on the formula bar line (which does work), nothing happens when I switch between workbooks. The formula bar remains hidden when I open another workbook etc.)

    Here is the code I am using;

    PHP Code: 
    Private Sub Workbook_Activate()
    If 
    CommandBars("Ribbon").Height 0 Then CommandBars.ExecuteMso "MinimizeRibbon"
    Application.DisplayStatusBar True
    End Sub 
    PHP Code: 
    Private Sub Workbook_Deactivate()
    If 
    CommandBars("Ribbon").Height 0 Then CommandBars.ExecuteMso "MinimizeRibbon"
    Application.DisplayStatusBar True

    End Sub 
    Any ideas?

    Thanks!

  2. #2
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Hide ribbon/formula bar for this workbook only

    maybe this?

    Sub Workbook_Open()
    CommandBars.ExecuteMso "HideRibbon"
    End Sub

    HTH

  3. #3
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: Hide ribbon/formula bar for this workbook only

    Quote Originally Posted by LFKim2018 View Post
    CommandBars.ExecuteMso "HideRibbon"
    HTH
    For some reason I get a 'invalid procedure call or argument' error with this one.'

    Quote Originally Posted by LFKim2018 View Post
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
    And this one runs but doesn't actually do anything? The ribbon stays as it is. Maybe because I'm running Excel for Mac?

  4. #4
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Hide ribbon/formula bar for this workbook only

    actually I had experienced same problem as you. I had consulted other forum for this and no definite procedure can remedy it.
    Pls look for the "pin" icon at the extreme right side of the ribbon - click it before running your program or workbook.

    also maybe you would want to try the following snippet:

    If Application.CommandBars("Ribbon").Height >= 100 Then
    SendKeys "^{F1}"
    End If


    include this in private sub workbook_open

    sincerely hoping this would help

  5. #5
    Registered User
    Join Date
    04-24-2016
    Location
    Johannesburg
    MS-Off Ver
    Office 365
    Posts
    1

    Re: Hide ribbon/formula bar for this workbook only

    LFKim's solution to hide the ribbon (see below) works in a workbook macro.

    But be careful it only work when screenupdating is true.


    Private Sub Workbook_Open()

    Application.ScreenUpdating = True

    If Application.CommandBars("Ribbon").Height >= 100 Then
    SendKeys "^{F1}"
    End If

    End Sub

  6. #6
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Hide ribbon/formula bar for this workbook only

    I think this is much better. Add this to ThisWorkbook

    Private Sub Workbook_Open()
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
    End Sub

    '** it is advisable to revert to the default > unhide the ribbon

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
    End Sub

    this time I hope this helps

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA to hide ribbon, formula bar and worsheets in only selected workbook
    By rahul_ferns76 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2022, 03:55 PM
  2. hide ribbon and formula bar on 1 workbook
    By MP1989 in forum Excel General
    Replies: 5
    Last Post: 07-05-2018, 09:47 AM
  3. [SOLVED] Hide Ribbon
    By EssoExplJoe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2017, 10:32 AM
  4. Replies: 2
    Last Post: 07-24-2017, 11:12 AM
  5. [SOLVED] Hide Ribbon
    By pedjvak in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-31-2013, 03:01 AM
  6. VBA to hide ribbon (not toolbar) on open workbook, and show on close workboo.
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2012, 04:33 AM
  7. Hide Ribbon on Workbook Open
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2012, 09:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1