开发者

Minimize the Office Ribbon with VBA?

I haven't searched real ha开发者_高级运维rd recently but in the past I have searched high and low to figure out a way to minimize the ribbon with VBA code. For me, most of my users have no use for the ribbon in Access, I would be very happy if I could reclaim the screen real estate for them.

I know I could train them to minimize it but...well...they are users, not computer geeks. :-)


If your database is set up to display a particular form when it's opened, you could put this code in the form's open event:

Private Sub Form_Open(Cancel As Integer)
    Call HideRibbon
End Sub

Here is the HideRibbon sub:

Public Sub HideRibbon()
    'Access versions before 2007 did not have ribbon '
    'ignore error: '
    '2094, <App Name> can't find the toolbar 'Ribbon.'
    On Error Resume Next
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    On Error GoTo 0
End Sub

Edit: I changed the HideRibbon sub to eliminate On Error Resume Next. It does what I want in Access 2003 and 2007. Not sure about the string value returned by SysCmd(acSysCmdAccessVer) in all the earlier Access versions, or future Access versions.

Public Sub HideRibbon()
    'Access versions before 2007 did not have ribbon '
    If Val(SysCmd(acSysCmdAccessVer)) >= 12 Then
        DoCmd.ShowToolbar "Ribbon", acToolbarNo
    End If
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜