Gustav Brock
gustav at cactus.dk
Fri Feb 8 10:32:38 CST 2013
Hi Stuart
That is indeed strange. I cannot explain.
Now, for anyone to use, here is a simple function that will collapse, enable
("un-collapse"), or toggle the collapsing of the ribbon:
<code>
Public Function EnableRibbon(Optional ByVal varEnable As Variant) As Boolean
' Set or toggle if the Ribbon should be collapsed or enabled.
'
' 2013-02-08. Cactus Data ApS, CPH.
'
' Can be used with AutoExec macro to minimize the Ribbon at launch:
' EnableRibbon(False)
' Height of Ribbon when enabled: 141
' Height of Ribbon when collapsed: 53
Const clngRibbonHeight As Long = 97
Const cstrRibbonName As String = "Ribbon"
Dim booEnabled As Boolean
' Continue on error and toggle the collapsing of the Ribbon.
On Error Resume Next
' Make the Ribbon visible as a hidden ribbon cannot be controlled.
DoCmd.ShowToolbar cstrRibbonName, acToolbarYes
' Measure if the Ribbon is collapsed or enabled.
booEnabled = (Application.CommandBars(cstrRibbonName).Height >
clngRibbonHeight)
If IsMissing(varEnable) Or (booEnabled Xor CBool(varEnable)) Then
' Toggle the collapsing of the Ribbon.
CommandBars.ExecuteMso "MinimizeRibbon"
booEnabled = Not booEnabled
End If
' Return the current state of the Ribbon.
EnableRibbon = booEnabled
End Function
</code>
/gustav
-----Oprindelig meddelelse-----
Fra: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] På vegne af Stuart McLachlan
Sendt: 8. februar 2013 15:36
Til: Access Developers discussion and problem solving
Emne: Re: [AccessD] A2012 Ribbon collapse (not hide) from code
The other interesting snippet is in Access 2010 VBA Help:
CommandBars.ExecuteMso Method
" Note
The Microsoft Office Assistant has been deprecated in the 2007 release of
the Microsoft Office system
And yet they introduced this ExexuteMSO parameter in Access 2010. WTF?
--
Stuart
On 8 Feb 2013 at 13:39, Gustav Brock wrote:
> Hi Stuart
>
> Thanks. So did I. Searched for minimize instead of collapse and found by
Albert D. Kallal:
>
>
http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/f8e6397f-fb63
-4508-a64c-5119303dce31
>
> Now, the big question is how to maximize it when minimized??
> This is where the intuitive part comes in. I tried, of course, with
> all the obvious variations - then returned to the thread and browsed to
the bottom:
>
> <quote>
> If I use the same line of code to hide the ribbon in the OnClose
> property, the ribbon is restored. Not completely intuitive, I think,
> that minimizing something that's minimized results in something maximized.
> </quote>
>
> You gotta love that kind of logic.
> Time for Friday beer and weekend.
>
> /gustav
>
> -----Oprindelig meddelelse-----
> Fra: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] På vegne af Stuart
> McLachlan
> Sendt: 8. februar 2013 13:06
> Til: Access Developers discussion and problem solving
> Emne: Re: [AccessD] A2012 Ribbon collapse (not hide) from code
>
> Just discovered, Access 2010:
>
> CommandBars.ExecuteMso "MinimizeRibbon"
>
> --
> Stuart
>
> On 8 Feb 2013 at 22:00, Stuart McLachlan wrote:
>
> > 2007/10 I'm guessing it will work in 2012:
> >
> > A real kludge, but I've never found an alternative.
> >
> > If CommandBars("ribbon").Height > 100 Then SendKeys "^{F1}", True
> > End If
> >
> > --
> > Stuart
> >
> > On 8 Feb 2013 at 11:51, Gustav Brock wrote:
> >
> > > Hi all
> > >
> > > Is this possible? It's easy to _hide_ , but how to collapse (or
minimize)?
> > > Also, client is not interested in custom ribbons; the default is fine.
> > >
> > > /gustav