如何通过C#确定单词2010中的页码 [英] How to determine the page number in word 2010 through C#

查看:101
本文介绍了如何通过C#确定单词2010中的页码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过C#确定单词2010中的当前页码?。  我需要在每个页面的标题中的条形码中添加页码。  页面数可能会有所不同,在生成文档之前是未知的。



Leonard Swarczinski软件开发商邮政中心国际

How to determine the Current page number in word 2010 through C#?.   I need to add the page number in a bar code in the header of each page.   The number of pages may vary and is not known before the document is generated.


Leonard Swarczinski Software Developer Postal Center International

推荐答案

嗨Leonard,

Hi Leonard,

下面是一个关于如何浏览整个word文档并获取当前页码的示例:

Below is a sample about how to go through the whole word document and get the current page number:

        private void button1_Click(object sender, EventArgs e)
        {
            var app = Globals.ThisAddIn.Application;

            long currentPageNum;

            long totalPageNum = app.ActiveDocument.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages);

            do
            {
                currentPageNum = app.Selection.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndPageNumber);

                app.Selection.GoToNext(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage);

                // add your code here
            } while (currentPageNum < totalPageNum);
        }

问候,

Jeffrey


这篇关于如何通过C#确定单词2010中的页码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆