我们如何可以在C打开具有特定的页码Word文件犀利? [英] how can we open a word file with specific page number in c sharp?

查看:170
本文介绍了我们如何可以在C打开具有特定的页码Word文件犀利?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何可以打开特定的页面数字文件。有谁能够plz帮助我.. ??

how can we open a word file with specific page number. can anybody plz help me..??

这是我用来打开文件的代码:

this is the the code i used to open the file:

public static Application Open(string fileName)
        {
            object fileNameAsObject = (object)fileName;
            Application wordApplication;
            try
            {
                wordApplication = new Application();
                object readnly = false;
                object missing = System.Reflection.Missing.Value;
                wordApplication.Documents.Open(ref fileNameAsObject, ref missing, ref readnly, ref missing,
                                                ref missing, ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing, ref missing);

                return wordApplication;
            }
            catch (Exception ex)
            {
                LogEntry log = new LogEntry();
                log.Categories.Add("Trace");
                log.Message = ex.ToString();
                Logger.Write(log, "Trace");
                throw new System.IO.FileLoadException("File cannot be opened");
            }
            finally
            {
                wordApplication = null;
            }
        }



我如何使用VBA代码(Selection.GoTo内容:= wdGoToPage,其中:= wdGoToFirst,计数:= 3,名称:=),相当于在C sharp来获取我想要的网页.. ???或任何其他建议?

how can i use the vba code (Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=3, Name:="" ) equivalent in c sharp to get the page that i want..??? or any other suggestions??

推荐答案

等价的C#互操作将是:

The equivalent C# interop would be:

object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToFirst;
object count = 3;

wordApplication.Selection.GoTo(ref what, ref which, ref count, ref missing);

这篇关于我们如何可以在C打开具有特定的页码Word文件犀利?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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