在处理文档时,Lewis可以选择一个单词或短语,右键单击它,然后选择“使用Bing搜索”选项。他对必应的搜索结果不满意,他更喜欢使用其他搜索引擎(例如Google)进行搜索。 Lewis想知道是否可以将其他搜索引擎添加到右键单击菜单,或者是否可以更改“使用Bing搜索”选项以使用其他搜索引擎。

刘易斯在右键单击上下文菜单上具有“使用必应搜索”选项的事实告诉我他正在使用Word 2010或Word2013。在Word 2007或Word 2016或更高版本中不存在此特定选项。版。

请参见_WindowsTips_站点上的提示。)请按照以下步骤进行修改:

。退出Word。

。启动注册表编辑器。

。找到并选择以下数据密钥。 (如下所示,此数据键适用于Word2013。如果您使用的是Word 2010,请将15.0更改为14.0。)

。选择编辑|新增|字符串值。注册表编辑器在注册表的右侧添加了一个新的字符串值,并允许您立即输入其名称。

。将新的字符串值命名为“ SearchProviderName”(不带引号)。

。右键单击新添加的字符串值,然后从出现的“上下文”菜单中选择“修改”。注册表编辑器将显示“编辑字符串”对话框。

。在“数值数据”字段中,输入“ Google”(不带引号。)

。单击确定。注册表编辑器中的信息已更新。

。再次选择Edit |新增|字符串值。注册表编辑器在注册表的右侧添加了另一个新的字符串值,您可以再次更改其名称。

。将新的字符串值命名为“ SearchProviderURI”(不带引号)。

。右键单击新添加的字符串值,然后从出现的“上下文”菜单中选择“修改”。注册表编辑器将显示“编辑字符串”对话框。

。 12.在“数值数据”字段中,输入“ https://www.google.com/search?q=“

(再次,不带引号)。

。单击确定。注册表编辑器中的信息已更新。

。关闭注册表编辑器。

。重新启动Word。

现在,继续并选择一些文本。右键单击它时,上下文菜单选项已从“使用Bing搜索”更改为“使用Google搜索”。如果您出于某种原因(出于某种原因)想要停止使用Google,然后再次开始使用Bing,只需删除在这些步骤中创建的两个注册表项即可。

前面的注册表修改不适用于Word 2007或Word 2016或更高版本。如前所述,这些版本都不包含“使用必应搜索”选项。 (Word 2016和更高版本包含“智能查找”选项,但没有“使用必应搜索”选项。)我们找到添加“用Google搜索”的唯一方法

上下文菜单的选项是向文档中添加一些较大的宏。例如,以下是一组宏,这些宏将在Word 2007系统上添加该选项。这些应添加到常规VBA模块中:

Option Explicit Dim oPopUp As CommandBarPopup Dim oCtr As CommandBarControl Private pWebAddress As String Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _   ByVal lpOperation As String, ByVal lpFile As String, _   ByVal lpParameters As String, ByVal lpDirectory As String, _   ByVal nShowCmd As Long) As Long

Sub BuildControls()

Dim oBtn As CommandBarButton     'Make changes to the Add-In template     CustomizationContext = ThisDocument.AttachedTemplate     'Prevent double customization     Set oPopUp = CommandBars.FindControl(Tag:="custPopup")

If Not oPopUp Is Nothing Then GoTo Add_Individual     'Add PopUp menu control to the top of the "Text" short-cut menu     Set oPopUp = CommandBars("Text").Controls.Add(msoControlPopup, , , 1)

With oPopUp         .Caption = "Search With Google"

.Tag = "custPopup"

.BeginGroup = True     End With     Set oBtn = oPopUp.Controls.Add(msoControlButton)

With oBtn         .Caption = "Google"

.FaceId = 940         .Style = msoButtonIconAndCaption         .OnAction = "WebPage"

End With     Set oBtn = Nothing Add_Individual:

'Or add individual commands directly to menu     Set oBtn = CommandBars.FindControl(Tag:="custCmdBtn")

If Not oBtn Is Nothing Then Exit Sub     'Add control using built-in ID 758 (Boo&kmarks...)

Set oBtn = Application.CommandBars("Text").Controls.Add(msoControlButton, 758, , 2)

oBtn.Tag = "custCmdBtn"

If MsgBox("This action caused a change to your Add-In template." _       & vbCr + vbCr & "Recommend you save those changes now.", _       vbInformation + vbOKCancel, "Save Changes") = vbOK Then           ThisDocument.Save     End If     Set oPopUp = Nothing     Set oBtn = Nothing lbl_Exit:

Exit Sub End Sub
Sub RemoveContextMenuItem ()

'Make command bar changes in Add-In template     CustomizationContext = ThisDocument.AttachedTemplate     On Error GoTo Err_Handler     Set oPopUp = CommandBars("Text").Controls("Search With Google")

'Delete individual commands on the PopUp menu.

For Each oCtr In oPopUp.Controls         oCtr.Delete     Next     'Delete the PopUp itself.

oPopUp.Delete     'Delete individual custom commands on the Text menu.

Reenter:

For Each oCtr In Application.CommandBars("Text").Controls         If oCtr.Caption = "Boo&kmark..." Then             oCtr.Delete             Exit For         End If     Next oCtr     If MsgBox("This action caused a change to your Add-In template." _       & vbCr + vbCr & "Recommend you save those changes now.", _       vbInformation + vbOKCancel, "Save Changes") = vbOK Then         ThisDocument.Save     End If     Set oPopUp = Nothing     Set oCtr = Nothing     Exit Sub Err_Handler:

' MsgBox Err.Number     Resume Reenter End Sub Public Sub WebPage()

pWebAddress = "https://www.google.com/search?q=" & Selection.Text     Call NewShell(pWebAddress, 3)

End Sub Public Sub NewShell(cmdLine As String, lngWindowHndl As Long)

ShellExecute lngWindowHndl, "open", cmdLine, _       Selection.Text, Selection.Text, 1 End Sub

为了将“使用Google搜索”选项添加到上下文菜单,只需运行BuildControls宏。如果以后要删除该选项,则可以运行RemoveContextMenuItem宏。

这些宏基于格雷格·麦克西(Greg Maxey)在其网站上所做的工作,这里:

https://gregmaxey.com/word_tip_pages/customize_shortcut_menu.html

如前所述,这些宏只能在Word 2007系统上运行。由于Greg在其网站上讨论的原因,如果不进行一些相当大的修改,它们将无法在Word 2016或更高版本的系统上运行,并且由于Microsoft继续进行的更改,即使在修改后它们也可能不稳定。

注意:

如果您想知道如何使用此页面(或_WordTips_网站上的任何其他页面)中描述的宏,我准备了一个包含有用信息的特殊页面。

_WordTips_是您进行经济有效的Microsoft Word培训的来源。

(Microsoft Word是世界上最流行的文字处理软件。)本技巧(166)适用于Microsoft Word 2007、2010、2013、2019和Office 365中的Word。