|
使用类似下面的函数:
Public Function AllowMenus(CmdBarName As String, CmdbarEnabled As _
Boolean)
'============================================================='
'This function has two arguments: CmdbarName is a string that '
'passes the name of the command bar that the code enables or '
'disables. CmdBarEnabled is a Boolean value in which you pass '
'"True" or "False" in order to enable or disable the command '
'bar being modified. '
' '
'Example: To disable the command bar "NorthwindCustomMenuBar" '
'in the Northwind sample database, use the following: '
' '
'AllowMenus("NorthwindCustomMenuBar",False) '
'============================================================='
Dim Cmdbar As CommandBar, Cbct As CommandBarControl
On Error GoTo Err_AllowMenus
Set Cmdbar = CommandBars(CmdBarName)
If Cmdbar.Visible = False Then Cmdbar.Visible = True
For Each Cbct In Cmdbar.Controls
Cbct.Enabled = CmdbarEnabled
Next Cbct
Exit_AllowMenus:
Exit Function
Err_AllowMenus:
MsgBox "Error " & CStr(Err) & " " & Err.Description & _
" has occurred in the AllowMenus Function", vbOKOnly, _
"Error Detected"
Resume Exit_AllowMenus
End Function
使用方法: AllowMenus("你的工具条名", False)
以上函数摘自微软,详细原文请参照:
http://support.microsoft.com/?kbid=202308 |
|