VBA All select Word Current page code

Source: Internet
Author: User
Tags goto

The function of the following code is to select the current page of the Word document, and note that it is the current page, the page where the insertion bar is located, not the full text.

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

Note that the above code is used in a VBA environment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.