Dzwebs.Net

撰写电脑技术杂文十余年

VBA全选word当前页代码

Admin | 2012-5-1 8:41:14 | 被阅次数 | 9627

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  下面的代码的功能是,全选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
    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环境下使用。


该杂文来自: Word杂文

上一篇:VBA判断Word的选择性粘贴是否选择无格式文本

下一篇:Word段前段后间距的设置

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计