选定当前页文本(VBA) Home » 编程开发 » 选定当前页文本(VBA) 功能简介:有时需要选定光标所在页的整页文本,此代码将以右键方式作用(右击/选定当前页命令) Private Sub Document_Close() On Error Resume Next Application.CommandBars(“Text”).Controls(“选定当前页”).Delete ‘恢复原有菜单 End Sub ‘———————- Private Sub Document_Open() Dim Half As Byte On Error Resume Next Dim NewButton As CommandBarButton Application.CommandBars(“Text”).Controls(“选定当前页”).Delete ‘预防性删除 Half = Int(Application.CommandBars(“Text”).Controls.Count / 2) ‘中间位置 Set NewButton = Application.CommandBars(“Text”).Controls.Add(Type:=msoControlButton, Before:=Half) With NewButton .Caption = “选定当前页” ‘命令名称 .FaceId = 100 ‘命令的 FaceId .Visible = True ‘可见 .OnAction = “SelectCurrentPage” ‘指定响应过程名 End With End Sub ‘———————- Sub SelectCurrentPage() Dim CurrentPageStart As Long, CurrentPageEnd As Long Dim CurrentPage As Integer, Pages As Integer On Error Resume Next With Selection CurrentPage = .Information(wdActiveEndPageNumber) ‘取得当前页页码 Pages = .Information(wdNumberOfPagesInDocument) ‘取得文档总页数 ‘返回当前页起点位置 CurrentPageStart = .GoTo(What:=wdGoToPage, Which:=wdGoToNext, Name:=CurrentPage).Start If CurrentPage = Pages Then ‘两者相等则最后位置为文档最后位置 CurrentPageEnd = ActiveDocument.Content.End Else ‘否则则为下一页的起点(本页的最后位置) CurrentPageEnd = .GoTo(What:=wdGoToPage, Which:=wdGoToNext, Name:=CurrentPage + 1).Start End If ActiveDocument.Range(CurrentPageStart, CurrentPageEnd).Select End With End Sub 往往教导我们大家要好好学习天天向上,要永不言弃坚持到底百折不挠宁死不屈, 相关文章: 如何在网页中实现右上角“平方”、右下角那种数字的写法? position的四个属性 RangeSeekBarView 选定范围值的控件 例题3.9 动态最大连续和 UVa1400 简单四则运算计算器 liangkaiming的专栏 【JavaScript】获取当前页的URL与window.location.href kkmdmcgxi的专栏 非常简单的js双向数据绑定框架(三):js model黑科技 Pub/Sub 发布订阅 你感兴趣的文章: 微信订阅号申请流程 微信订阅号申请条件 制作Appstore预览视频并上传 家用灯双控开关接线方法图解 小米4电池续航能力怎么样?小米手机4电池耐用么? 华硕主板acpia5蓝屏怎么解决 Tomcat中使用commons-io-2.5发生的错误java.lang.ClassNotFoundE 标签云: 亚洲高清电影在线, 免费高清电影, 八戒影院夜间, 八戒电影最新大片, 出轨在线电影, 午夜电影院, 在线影院a1166, 在线电影院, 在线观看美剧下载, 日本爱情电影, 日韩高清电影在线, 电影天堂网, 直播盒子app, 聚合直播, 高清美剧, 高清美剧在线观看 EhViewer-E站, E站, E站绿色版, qqmulu.com, qq目录网, qq网站目录,