vba 统计Word 字数、页数等信息.doc_第1页
vba 统计Word 字数、页数等信息.doc_第2页
vba 统计Word 字数、页数等信息.doc_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

VBA 统计Word 字数、页数等信息方法一. 使用Document.BuiltInDocumentProperties 方法统计 适用于Document对象和Template 对象。返回一个 DocumentProperties 集合,该集合代表了指定文档的所有内置的文档属性。 可使用的参数有: wdPropertyAppName 应用程序名. wdPropertyAuthor 作者. wdPropertyBytes 字节数. wdPropertyCategory 类别. wdPropertyCharacters 字符数. wdPropertyCharsWSpaces 字符数(计空格). wdPropertyComments 批注. wdPropertyCompany 公司. wdPropertyKeywords 关键词. wdPropertyLastAuthor 上一个作者. wdPropertyLines 行数. wdPropertyManager 经理. wdPropertyNotes 注释. wdPropertyPages 页数. wdPropertyParas 段数. wdPropertyRevision 修订次数. wdPropertySecurity 安全性. wdPropertySubject 主题 . wdPropertyTemplate 模板. wdPropertyTimeCreated 创建时间 . wdPropertyTimeLastPrinted 上次打印时间. wdPropertyTimeLastSaved 上次保存时间. wdPropertyTitle 标题. wdPropertyVBATotalEdit 编辑时间总计. wdPropertyWords 字数 . 如要统计一篇活动word文档的字数:ActiveDocument.BuiltInDocumentProperties(wdPropert yWords) 方法二.使用ActiveDocument.ComputeStatistics方法统计 可使用的参数如下: wdStatisticCharacters 字符数. wdStatisticCharactersWithSpaces 字符数(计空格). wdStatisticFarEastCharacters 中文字符和朝鲜文. wdStatisticLines 行数. wdStatisticPages 页数. wdStatisticParagraphs 段数. wdStatisticWords 字数 . 使用如下: 统计活动文档的字数(包括脚注): 1.应用于 Document 对象的 ComputeStatistics 方法。 ActiveDocument.ComputeStatistics(Statistic:=wdStat isticWords, _ IncludeFootnotesAndEndnotes:=True) 2.应用于 Range 对象的 ComputeStatistics 方法。 .Range.ComputeStatistics(Statistic:=wdStatisticWor ds, _ IncludeFootnotesAndEndnotes:=True) 例:显示 Report.doc 第一段中的字数和字符数。 Set myRange = Documents(Report.doc).Paragraphs(1).Range wordCount = myRange.ComputeStatistics(Statistic:=wdStatisticWo rds) charCount = myRange.ComputeStatistics(Statistic:=wdStatisticCh aracters) MsgBox The first paragraph contains & wordCount _ & words and a total of & charCount & characters. 统计活动文档的字数也可以写成 ActiveDocument.Range.ComputeStatistics(wdStatistic Words) 方法三、利用ActiveWindow.Panes(1).Pages.Count 属性(比较好的方法)Sub Get_wordpages()打开当前目录下面的市场研究实务word文档Documents.Open Filename:=ThisWorkbook.Path & 市场研究实务.doc统计页数MsgBox Documents(市场研究实务.doc).ActiveWindow.Panes(1).Pages.CountDocuments.Close SaveChanges:=FalseEnd Sub方法四、直接使用Count属性,但这种方法统计不准,可以统计隐藏文本内容。 使用如下: 统计段数 ActiveDocument.Paragraphs.Count 统计字数 ActiveDocument.Words.Count 方法四. 直接调用word的内建方法Dialogs() 统计中文字数: Dialogs(wdDial

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论