1

https://stackoverflow.com/a/11624006/1553562

我如何将我的搜索限制在作为用户输入的有限范围的文档中???

4

1 回答 1

3

这将让您指定从第 3 页到第 20 页的范围

Sub Sample()
    Dim rng As Range
    Dim StartPage As Long, EndPage As Long

    StartPage = 3: EndPage = 20

    Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=StartPage

    Set rng = Selection.Range

    Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=EndPage

    rng.End = Selection.Bookmarks("\Page").Range.End

    '~~> Now you have got your range. Do the necessary action here
    With rng

    End With
End Sub
于 2012-08-01T07:55:27.017 回答