今天图老师小编要向大家分享个VBA全选word当前页代码教程,过程简单易学,相信聪明的你一定能轻松get!
【 tulaoshi.com - Word教程 】
下面的代码的功能是,全选word文档的当前页,注意,是当前页,即插入条所在的页,而不是全文。
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
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)CurrentPageEnd = ActiveDocument.Content.End
Else
CurrentPageEnd = Selection.GoTo(what:=wdGoToPage, Which:=wdGoToNext, Name:=Currentpage + 1).start
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)End If
Set myRange = ActiveDocument.Range(CurrentPageStart, CurrentPageEnd)
myRange.Select
注意,以上代码在VBA环境下使用。
来源:http://www.tulaoshi.com/n/20160219/1589894.html
看过《VBA全选word当前页代码》的人还看了以下文章 更多>>