Msword搜索宏
当我在未指定范围的情况下进行搜索时,搜索开始在活动页面上:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "house"
.Replacement.Text = "apartment"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
End With
Selection.Find.Execute
如果我使用范围,它总是从范围的开头开始,
ActiveDocument.StoryRanges(wdMainTextStory).select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "house"
.Replacement.Text = "apartment"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
End With
Selection.Find.Execute
有人知道一种在使用范围时在活动页面中启动搜索的方法吗?
通过Active页面,我的意思是带有光标的页面。
另外,我需要搜索脚注和尾注。这就是使用故事范围的原因,这似乎迫使搜索从文档的开头开始。
When I search without specifying the range, the search starts at the active page:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "house"
.Replacement.Text = "apartment"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
End With
Selection.Find.Execute
If I use a range, it always starts at the beginning of the range
ActiveDocument.StoryRanges(wdMainTextStory).select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "house"
.Replacement.Text = "apartment"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = True
End With
Selection.Find.Execute
Anyone know a way to start the search in the active page while using a range?
By active page, I mean the page with the cursor.
Also, I need to search footnotes and endnotes. That's the reason for using storyranges, which seems to force the search to start at the beginning of the document.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如:
请注意,由于您已经设置了
.wrap = wdfindContinue
它在查找
开始时没有区别,因为它会搜索整个文档。For example:
Please note that as you have set
.Wrap = wdFindContinue
it makes no difference whereFind
starts as it will search the entire document anyway.