在 Microsoft Word 中,通常忽略 Add 方法的 Temporary 参数(CommandBarControls 对象)。因此,在向命令栏上的菜单栏添加控件按钮时,它将保留在 Normal.dot 模板中,无论是否将 Temporary 参数设置为 True。要从 Normal.dot 模板中删除不需要的菜单项,可以使用下列方法之一。
Sub ResetAllCommandBars()
Dim mnu As CommandBar
'Error handler skips over custom toolbars,
'which can't be reset
On Error Resume Next
For Each mnu In Application.CommandBars
mnu.Reset
Next mnu
End Sub
本示例仅重置 Word 中菜单栏上的项而不是所有工具栏。Sub ResetMenuBar()
Dim mnu As CommandBar
For Each mnu In Application.CommandBars
If mnu.Name = "Menu Bar" Then
mnu.Reset
End If
Next mnu
End Sub