Results 1 to 4 of 4
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    Minimizing and Maximizing Ribbon in 2007

    I am trying to minimize (NOT HIDE) the Ribbon when opening the Access 2007 database and Maximize when closing it. I snagged the following code from the internet but when I call it I get the following error with "QueryValue" highlighted:



    "Compile Error: Sub or Function not defined".

    Code:
    Public Sub MinRibbon()
        
        Dim intRibbonState     As Integer
        
        intRibbonState = QueryValue("Software\Microsoft\Office\12.0\Common\Toolbars\Access", _
                         "QuickAccessToolbarStyle")
        If intRibbonState = 0 Then
            SendKeys "^{F1}", False
        End If
        DoEvents
    End Sub
    
    Public Sub MaxRibbon()
        
        Dim intRibbonState As Integer
        
        intRibbonState = QueryValue("Software\Microsoft\Office\12.0\Common\Toolbars\Access", _
                         "QuickAccessToolbarStyle")
        
        If intRibbonState = 4 Then
           'ribbon in Autohide state, max it
            SendKeys "^{F1}", False
        End If
        DoEvents
    End Sub
    I have the code stored in a module named dMinMaxRibbon

    I have the following code on my switchboard which opens when the database opens:

    Code:
    Private Sub Form_Open(Cancel As Integer)
        dMinMaxRibbon.MinRibbon
    End Sub
    I'm new to VBA programming and self taught, so please try to explain not only what the error is and how to fix it but why it is an error.

    Please note: using Access 2007, thus
    Code:
    CommandBars.ExecuteMso "MinimizeRibbon"
    will not work (2010+ only)

    Also, is there a way to call the Sub MaxRibbon upon closing the database instead individual forms since the switchboard will be opening and closing a lot?

    Thanks for any and all help.
    Last edited by newbieX; 09-12-2014 at 10:58 AM. Reason: deleted space between Query and Value

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    QueryValue is a VBA custom function. Apparently the function being called doesn't exist. You need to create the function. Better take another look at your code source. You appear to be missing some.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111
    Code:
    RibbonState = (CommandBars("Ribbon").Controls(1).Height < 100)
    
    Select Case RibbonState
        Case True
            'Do nothing, already minimized
        Case False
            ' Sends key that minimizes ribbon
            SendKeys "^{F1}", False
    End Select
    This code works, but I could not find solution as to where I can write code to maximize ribbon when exiting database. Putting it in the forms when closed was not global enough. Solution to that was to make the switchboard not visible instead of closing, that way I could put the code in the form close event of the switchboard, which was only closed on exiting the database. Not ideal but works.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So this is solved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-28-2013, 05:48 PM
  2. Minimizing database screen
    By jparker1954 in forum Access
    Replies: 3
    Last Post: 08-30-2011, 08:49 AM
  3. Invalidating dropdown control on Access 2007 ribbon
    By kenwarthen in forum Programming
    Replies: 0
    Last Post: 08-16-2010, 09:29 AM
  4. Access 2007 Ribbon
    By jgelpi in forum Programming
    Replies: 2
    Last Post: 07-21-2009, 04:05 PM
  5. How to add user-defined ribbon in access 2007
    By ali-gagi in forum Access
    Replies: 1
    Last Post: 07-02-2009, 07:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums