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.