我正在尝试找出一种自动导航窗格的方法,这样当您打开文档时,它会自动搜索并显示该文档中所有单词注释的结果。手动方式是单击导航搜索栏旁边的下拉箭头,选择查找下的注释,然后选择所有审阅者。有没有办法实现自动化?
谢谢!
以下代码: *代码可以正常工作,但实际上并没有显示任何注释。如果手动执行此过程,它将显示文档中的所有注释。如果我使用此宏,它将说没有找到结果,即使搜索栏具有相同的信息。我尝试将范围定义为整个文档,但它没有奏效。
Sub AutoOpen()
' Activate/Deactivate Navigation Pane
' Collapse All, to only show heading level 1
Set myRange = ActiveDocument.Content
ActiveWindow.DocumentMap = True
If ActiveWindow.DocumentMap = True Then
' Ctrl-F = Find --> this sets the cursor at the top of the navigation pane
' ^ = Ctrl key
' + = Shift key
SendKeys "^(f){TAB}{ENTER}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}
{ENTER}{DOWN}{ENTER}"
End If
ActiveWindow.View.ShowComments = True
End Sub
答案 0 :(得分:0)
我不确定它是您问题的准确答案,但您的尝试帮助我找到了使用新Word2016导航窗格的创造性方法。我设计了一个userFrom来选择要搜索的特殊字符。在我的例子中,要让导航窗格显示项目,我不得不关闭表单并执行ActiveDocuemnt.activate。然后,只有导航窗格显示其结果。感谢。
DoEvents
Application.ScreenUpdating = False
' put text in word, copy to clipboard, and undo it
Dim s As Long
Dim e As Long
s = Selection.start
Selection.TypeText "the text I want to search that comes from my userform"
e = Selection.start
Selection.SetRange start:=s, End:=e
Selection.Copy
ActiveDocument.Undo
Application.ScreenUpdating = True
' make document map active
ActiveWindow.DocumentMap = True
' fortunately input field has focus, erase any content, paste
SendKeys "^(f){backspace}^{v}{Enter}"
Me.hide ' I hide my user form
ActiveDocument.Activate ' i activate the active document to see the result