+ Reply to Thread
Results 1 to 4 of 4

Opening Excel With No Menus

Hybrid View

  1. #1
    Registered User
    Join Date
    07-02-2007
    Posts
    1

    Opening Excel With No Menus

    Hi all, Im new to the scene, let me just say that ExcelTip comes highly recommended by many!

    Heres my question:
    When opening an excel file is it possible to have it open with no menus or anything, just the spreadsheet part? I want my spreadsheet with macro buttons to look like a standalone program!

    Can this be accomplished with some sort of macro, or there is a program out there that can do this?

    Cheers,
    Graham

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    You can't remove all toolbars but it won't remove the top menu with file etc


    http://www.ozgrid.com/VBA/toolbar-remove-restore.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    No Menu Or Toolbars Is Possible

    You can remove all the Toolbars and the Menu Bar.
    I think these do what you want.
    They remove/replace all the "visible" Toolbars, disable the worksheet Menu Bar and allow you to use your own custom Caption on the App.
    They contain ample comments so you should be able to follow them.
    Be careful!

    Private Sub Workbook_Open()
    '
    ' When the workbook is opened turn screen updating off.  Make the Parameters worksheet active.  Record in the relevant
    ' table on the worksheet whether each built in Toolbar is visible or not.  Hide the Formula Bar and Status Bar.  Hide
    ' all the built in Toolbars that are visible and disable the Worksheet Menu Bar.  Make the Menu worksheet active,
    ' turn screen updating on and show the MenuForm.
    '
        Application.ScreenUpdating = False  ' Turn off screen updating
        Worksheets("Parameters").Activate  ' Make the Parameters worksheet active.
        Dim R As Range  ' Declare the local variable R as a range.
        Set R = ActiveSheet.Range("D45")  ' Set the local variable R equal to cell D45.
        ' The following "For" loop records whether each Toolbar is visible or not.  It checks whether each Toolbar is
        ' visible and makes the value of the cells, referenced from the local variable r, equal to the boolean result
        ' (ie True or False).  Only the first 20 Toolbars are interrogated.
        For i = 1 To 20
            R.Cells(i, 1).Value = Application.CommandBars(i).Visible
        Next
        With Application
            .DisplayFormulaBar = False  ' Hide the Formula Bar.
            .DisplayStatusBar = False  ' Hide the Status Bar.
        End With
        ' The following "For" loop hides all the Toolbars.
        For Each bar In Application.CommandBars  ' For each command bar.
            If bar.Enabled Then
                ' Specifies that when a run-time error occurs, control goes to the statement immediately following the
                ' statement where the error occurred where execution continues.  This line is required because the
                ' the first command bar accessed is the Worksheet Menu Bar which cannot be hidden and generates a run-
                ' time error.
                On Error Resume Next
                If bar.BuiltIn And bar.Visible Then bar.Visible = False
            End If
        Next
        Application.CommandBars("Worksheet Menu Bar").Enabled = False  ' Disable the Worksheet Menu Bar.
        Worksheets("Menu").Activate  ' Make the Menu worksheet active.  This is a "blank" worksheet with no gridlines.
        Worksheets("Menu").EnableSelection = xlUnlockedCells  ' Only unlocked cells can be selected on the 'Menu' worksheet.
        Application.Caption = "Give Your App. It's Own Caption!"
        Application.ScreenUpdating = True  ' Turn on screen updating.
        Beep
        MenuForm.Show  ' Show the MenuForm Form.  This shows a menu on the "blank" worksheet.
    End Sub
    
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    '
    ' When the workbook is closed turn screenupdating off.  Make the Parameters worksheet active.  Enable the Worksheet
    ' Menu Bar.  Make the Toolbars that were visible when the file was open visible again by using the boolean values
    ' stored in the relevant table on the worksheet.  Display the Formula Bar and Status Bar.  Make the Menu worksheet
    ' active and turn screen updating on.
    '
        ' Application.ScreenUpdating = False  ' Turn off screen updating
        If ThisWorkbook.Saved = False Then      ' If the workbook has not been saved.
           intResponse = MsgBox("Do you want to save the changes made to '" & ActiveWorkbook.Name & "'?", 68, "Save " _
                & "File ")
        End If
        If intResponse = vbYes Then Save_File  ' If user responds "Yes" save the file.
        Worksheets("Parameters").Activate  ' Make the Parameters worksheet active.
        Application.CommandBars("Worksheet Menu Bar").Enabled = True  ' Enable the Worksheet Menu Bar.
        Dim R As Range  ' Declare the local variable r as a range.
        Set R = ActiveSheet.Range("D45")  ' Set the local variable r equal to cell D45.
        ' The following "For" loop makes each Toolbar that was visible when the file was opened visible again.  It reads
        ' the boolean value in the cell referenced from the local variable r and makes the relevant Toolbar visibility
        ' equal to this value (ie True or False).  Only the first 20 Toolbars are interrogated.
        For i = 1 To 20
            ' Specifies that when a run-time error occurs, control goes to the statement immediately following the
            ' statement where the error occurred where execution continues.  This line is required because the
            ' the Toolbar table on the Parameters worksheet is updated to show which Toolbars were visible when the file
            ' is opened.  Consequently if the file is not saved the user is asked if they want to save.  This generates
            ' a run-time error.
            On Error Resume Next
            Application.CommandBars(i).Visible = R.Cells(i, 1).Value
        Next
        With Application
            .DisplayFormulaBar = True  ' Display the Formula Bar.
            .DisplayStatusBar = True  ' Display the Status Bar.
        End With
        Worksheets("Menu").Activate  ' Make the Menu worksheet active.
        Application.ScreenUpdating = True  ' Turn on screen updating
    End Sub

  4. #4
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119
    I've put the code in the attached file.
    See if it suits your needs.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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