下面的代碼的功能是,全選word文檔的當(dāng)前頁(yè),注意,是當(dāng)前頁(yè),即插入條所在的頁(yè),而不是全文。 Dim CurrentPageStart As Long, CurrentPageEnd As Long, myRange As Range Dim Currentpage As Integer, Pages As Integer On Error Resume Next Currentpage = Selection.Information(wdActiveEndPageNumber) Pages = Selection.Information(wdNumberOfPagesInDocument) CurrentPageStart = Selection.GoTo(what:=wdGoToPage, Which:=wdGoToNext, Name:=Currentpage).start If Currentpage = Pages Then CurrentPageEnd = ActiveDocument.Content.End Else CurrentPageEnd = Selection.GoTo(what:=wdGoToPage, Which:=wdGoToNext, Name:=Currentpage + 1).start End If Set myRange = ActiveDocument.Range(CurrentPageStart, CurrentPageEnd) myRange.Select 注意,以上代碼在VBA環(huán)境下使用。 |
|