C# Microsoft.Office.Interop.Word怎么获取页数和字数?

用C#编程,循环文件夹下的所有word文件,获取每一个word的页数和字数太好了,谢谢!这个统计的字数是中英文、还有符号,所有的吧???和word中统计的不一样哟!... 用C#编程,循环文件夹下的所有word文件,获取每一个word的页数和字数
太好了,谢谢!这个统计的字数是中英文、还有符号,所有的吧???和word中统计的不一样哟!
展开
 我来答
dengjun9452005
2010-06-11 · TA获得超过655个赞
知道小有建树答主
回答量:144
采纳率:0%
帮助的人:188万
展开全部
using MSWord = Microsoft.Office.Interop.Word;
//方法内容
private MSWord.Application wordApp; //Word应用程序变量
private MSWord.Document wordDoc; //Word文档变量
private Object Nothing = Missing.Value;
//初始化
wordApp = new MSWord.ApplicationClass();
wordDoc = wordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
// 打开Word
object FileName = strPath;
object readOnly = false;
object isVisible = true;
wordDoc = wordApp.Documents.Open(ref FileName, ref Nothing, ref readOnly,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref isVisible, ref Nothing,
ref Nothing, ref Nothing, ref Nothing);

// 计算Word文档页数
MSWord.WdStatistic stat = MSWord.WdStatistic.wdStatisticPages;
int num = wordDoc.ComputeStatistics(stat, ref Nothing);

int wordNum=wordDoc.Characters.Count;//文档字数
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
博思aippt
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼word文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景... 点击进入详情页
本回答由博思aippt提供
创作者AkcX7kYRa5
2019-08-12 · TA获得超过3679个赞
知道大有可为答主
回答量:3036
采纳率:24%
帮助的人:431万
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式