1

序列“Alt”+ 单击会在 Office 2010 中创建一个非常烦人且持久的“研究”工具栏。

如何通过 VBA 删除它?

4

1 回答 1

1

您也可以通过 VBA 在 Outlook 中执行此操作。Office 2010 不再允许您通过大多数这些解决方案进行删除。

Word、PowerPoint 和 Excel 让您可以轻松使用它。只需使用:

Application.CommandBars("Research").Enabled = False

将从这些应用程序中禁用命令栏。


Outlook 需要更多麻烦,因为它同时使用资源管理器和检查器,在不同的上下文中,它们都启用了此命令栏。因此,解决方案分为两部分。

第一部分是设置WithEvents处理每个新 Inspector 的创建。通常,每当您打开消息/事件/等时,它们都会被创建/销毁。因此,即使您点击了每个当前的 Inspector,您的新 Inspector 也不会禁用命令栏。

将以下内容放入 VBA 编辑器中的 ThisOutlookSession (Alt+F11)。每个新的检查器(还有资源管理器,尽管我还没有创建资源管理器)都将禁用其命令栏。


Public WithEvents colInspectors As Outlook.Inspectors
Public WithEvents objInspector As Outlook.Inspector
Public WithEvents colExplorers As Outlook.Explorers
Public WithEvents objExplorer As Outlook.Explorer

Public Sub Application_Startup()
    Init_colExplorersEvent
    Init_colInspectorsEvent
End Sub
Private Sub Init_colExplorersEvent()
    Set colExplorers = Outlook.Explorers
End Sub

Private Sub Init_colInspectorsEvent()
    'Initialize the inspectors events handler
    Set colInspectors = Outlook.Inspectors

End Sub

Private Sub colInspectors_NewInspector(ByVal NewInspector As Inspector)
    Debug.Print "new inspector"
    NewInspector.commandbars("Research").Enabled = False
    'This is the code that creates a new inspector with events activated
    Set objInspector = NewInspector
End Sub
Private Sub colExplorers_NewExplorer(ByVal NewExplorer As Explorer)
    'I don't believe this is required for explorers as I do not think Outlook
    'ever creates additional explorers... but who knows
    Debug.Print "new explorer"
    NewExplorer.commandbars("Research").Enabled = False
    'This is the code that creates a new inspector with events activated
    Set objExplorer = NewExplorer
End Sub

但是,这只会使菜单从 Outlook 中的某些视图中消失。您仍然需要运行以下宏以将其从所有资源管理器中删除。当您关闭/重新打开 Outlook 时,我可以说这是持久的:

Private Sub removeOutlookResearchBar()

    'remove from main Outlook explorer
    Dim mExp As Explorer
    For Each mExp In Outlook.Explorers
        mExp.commandbars("Research").Enabled = False
    Next mExp

End Sub
于 2013-08-26T16:30:55.183 回答