繁体   English   中英

为什么在日语操作系统中字页数总是返回 1

[英]Why Word page count always returns 1 in Japanese Operating System

但它在英文操作系统中运行良好。 它还返回 Excel 和英语操作系统以及日语操作系统中的 Power point 文档的正确值。 日语操作系统中 Word 文档的页数仅面临问题

我已经尝试了三种类型的代码,但我仍然将总页数设为 1。

参考版本:Microsoft.Office.Interop.Word 版本 15.0.0.0 Visual Studio:2013 Microsoft Office:2016

方法:1:-

Microsoft.Office.Interop.Word.ApplicationClass appWordPageCount = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document DocPageCount = null;
Microsoft.Office.Interop.Word.WdStatistic staticPages = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
object missing = System.Reflection.Missing.Value;
DocPageCount = appWordPageCount.Documents.Open(fileNames);
wordPageCount = DocPageCount.ComputeStatistics(staticPages, ref missing);  // fetches page count of word files

方法:2

Microsoft.Office.Interop.Word.Application appWordPageCount = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document DocPageCount = null;
DocPageCount = appWordPageCount.Documents.Open(wordFile);
wordPageCount = DocPageCount.ActiveWindow.ActivePane.Pages.Count;

方法:3

Microsoft.Office.Interop.Word.ApplicationClass appWordPageCount = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document DocPageCount = null;
Microsoft.Office.Interop.Word.WdStatistic staticPages = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
object encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
DocPageCount = appWordPageCount.Documents.Open(ref fileNames, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                                    ref encoding, ref missing, ref missing, ref missing, ref missing, ref missing);
wordPageCount = DocPageCount.ComputeStatistics(staticPages, ref missing); 

提前感谢您的指导。

当 Word 应用程序视图模式为“Web 布局”时,它总是返回页数为 1。其中有三种视图模式,读取,打印布局,Web 布局。 所以在获取word文档的页数时,模式应该是打印布局。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM