从Word文件中读取目录 [英] Reading Table of contents from a word file

查看:100
本文介绍了从Word文件中读取目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,
我是Navaneeth,是Web开发的新手.我有一个疑问,希望有人能回答我的疑问.在这里.

我有第一页,其中包含文件上传器和确定"按钮.当我选择一个词文件并单击确定"按钮时,它将在第二页中显示该词文件的目录.我已经使用com对象来实现这一点.我已经使用了以下应用程序类.

//创建应用程序类的实例
ApplicationClass WordApp = ApplicationClass ();

//设置文件名和参数
对象 fileName = TheFile;
对象 readOnly = ;
对象 isVisible = true ;

//声明我不关心的参数
object <字体大小= 2>缺少= System.Reflection.
<字体颜色=#008080" size = 2>缺少 .Value;

//正在打开要检索目录的文档
文档 aDoc = WordApp.Documents.Open( ref fileName, ref 丢失, ref readOnly, ref 缺少, ref 丢失, ref 丢失, ref ,缺少 ref ref 丢失, ref 丢失, ref 丢失, ref isVisible, ref 丢失, 参考 丢失, ref 丢失, ref 缺少);

//为活动文档创建文档对象
文档 doc1 = WordApp.ActiveDocument;

///阅读内容后关闭文档
aDoc.Close(
ref 丢失, ref 丢失, ref 丢失);

Hi,
    I am Navaneeth and new to web development. I have a doubt and hope someone answers my doubt. Here it is.

I have a first page with a file uploader and a Ok button. When I select a word file and click the OK button it displays the table of contents of the word file in the second page. I have used com object to implement this. I have used the application class as follows.

//Creating instance of application class
ApplicationClass WordApp = new ApplicationClass();

//Setting file name and parameters
object fileName = TheFile;
object readOnly = false;
object isVisible = true;

//Declaring parameters that I dont care about
object missing = System.Reflection.Missing.Value;

//Opening the document to retrieve table of contents
Document aDoc = WordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);

//Creating a document object for the active document
Document doc1 = WordApp.ActiveDocument;

//Closing the document after reading the contents
aDoc.Close(
ref missing, ref missing, ref missing);

推荐答案

你好,Navaneeth

感谢您的发帖!不幸的是,目前没有论坛发布您要提问的问题,因此我建议您将问题发布到此处 希望有帮助!


这篇关于从Word文件中读取目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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