【发布时间】:2015-10-11 21:08:38
【问题描述】:
我正在尝试删除任何包含特定文本的页面,例如下面的句子 (strSearch =)。但是当我尝试运行宏时出现 5904 错误...有什么线索吗?
Sub DeletePages()
Dim strSearch As String
Dim rgeStart As Range
Set rgeStart = Selection.Range
strSearch = "Report the content of the ""StatusBar"" status bar message to the results."
With ActiveDocument.Range.Find
.Text = strSearch
Do While .Execute
With .Parent
.Select With Selection
.Bookmarks("\Page").Range.Delete
End With
End With
Loop
End With
rgeStart.Select
Application.Browser.Target = wdBrowsePage
End Sub
【问题讨论】:
-
正确的格式有助于发现问题...
-
哪行代码触发了错误?错误信息是什么?您是否尝试过单步执行代码以确保它符合您的预期?整个 Find 部分对我来说没有多大意义,但是您没有提供任何 cmets,因此不清楚您期望它做什么......
标签: string vba ms-word find selection