-------------------Ö£¼ÒÁú±àÒïÓÚMS OFFICE¿ª·¢Îĵµ
Òþ²ØºÍÏÔʾ²Ëµ¥ºÍ¹¤¾ßÀ¸
¿ÉÒÔÓÃCommandBar¶ÔÏóµÄVisibleÊôÐÔÀ´Òþ²ØºÍÏÔʾ¹¤¾ßÀ¸£¬µ±ÄãÏÔʾһ¸ö¹¤¾ßÀ¸µÄʱºò£¬Äã¿ÉÒÔÓÃPositionÊôÐÔÀ´Ö¸¶¨¹¤¾ßÀ¸Ó¦¸ÃÏÔʾÔÚÆÁÄ»µÄÄÄÒ»¸öµØ·½£¬ÀýÈ磬ÏÂÃæµÄÒ»¶Î³ÌÐòÐèÒªÈý¸ö²ÎÊý£¬strCBarName±íʾҪÏÔʾ»òÒþ²ØµÄ¹¤¾ßÀ¸Ãû³Æ£¬blnVisible±íʾÊÇÒþ²Ø»¹ÊÇÒªÏÔʾ£¬¿ÉÑ¡²ÎÊýlngPosition±íʾ¹¤¾ßÀ¸ÏÔʾµÄλÖã¬Ä¬ÈÏÊÇÏÔʾÔÚACCESS´°¿ÚµÄÉÏ·½£¬Ò²¿ÉÒÔÏÔʾÔÚ×ó¡¢ÓÒ»òÕßÊÇÏ·½¡£
Function CBToolbarShow(strCBarName As String, _
blnVisible As Boolean, _
Optional lngPosition As Long = msoBarTop) As Boolean
' This procedure displays or hides the command bar specified in the
' strCBarName argument according to the value of the blnVisible
' argument. The optional lngPosition argument specifies where the
' command bar will appear on the screen.
Dim cbrCmdBar As CommandBar
On Error GoTo CBToolbarShow_Err
Set cbrCmdBar = Application.CommandBars(strCBarName)
' Show only toolbars.
If cbrCmdBar.Type > msoBarTypeNormal Then
CBToolbarShow = False
Exit Function
End If
' If Position argument is invalid, set to the default
' msoBarTop position.
If lngPosition < msoBarLeft Or lngPosition > msoBarMenuBar Then
lngPosition = msoBarTop
End If
With cbrCmdBar
.Visible = blnVisible
.Position = lngPosition
End With
CBToolbarShow = True
CBToolbarShow_End:
Exit Function
CBToolbarShow_Err:
CBToolbarShow = False
Resume CBToolbarShow_End
End Function
ÒªÏÔʾһ¸ö²Ëµ¥À¸£¬¿ÉÒԲο¼ÒÔϵÄÒ»¸öº¯ÊýÀ´ÊµÏÖ£º
Function CBMenuBarShow(strCBarName As String) As Boolean
' ±¾º¯Êý¿ÉÒÔÏÔʾһ¸öÖ¸¶¨µÄ²Ëµ¥À¸£¬Èç¹ûÖ¸¶¨µÄ²Ëµ¥À¸²»´æÔÚ»òÕßÊÇ·Ç·¨µÄÃû³Æ£¬½«·µ»ØFALSE
Dim cbrCBarMenu As CommandBar
On Error GoTo CBMenuBarShow_Err
Set cbrCBarMenu = Application.CommandBars(strCBarName)
If cbrCBarMenu.Type <> msoBarTypeMenuBar Then
CBMenuBarShow = False
Exit Function
End If
With cbrCBarMenu
.Visible = True
End With
CBMenuBarShow = True
CBMenuBarShow_End:
Exit Function
CBMenuBarShow_Err:
CBMenuBarShow = False
Resume CBMenuBarShow_End
End Function
µ÷Ó÷½·¨£º? CBMenuBarShow ("Menu Bar")¡¯ÏÔʾÒѱ»Òþ²ØµÄÖ÷²Ëµ¥¡£