简体   繁体   English

如何使用C#处理Word文档

[英]How to work with word document using c#

I want to do the next, but don't know how to do it, please help me. 我想做下一个,但不知道该怎么做,请帮助我。

First, I open the Word document by 首先,我通过以下方式打开Word文档

wordApp.Documents.Open; 

then I try to save it by another name to make a copy using 然后我尝试用另一个名称保存它以使用

aDoc.SaveAs(ref saveas...);

Now I want to go through the savedAs document word by word. 现在,我想逐字逐个地浏览一下saveAs文档。 I need to get every word and go through the word letter by letter. 我需要得到每个单词,然后逐个字母地逐个单词。

So, actually I want to get the word, check it for some rules, then get read that word letter by letter and make changes (transliterate) to those letters, so in the end I will have the transliterated document. 因此,实际上我想得到该单词,检查它的某些规则,然后逐个字母地读取该单词并对这些字母进行更改(音译),因此最后我将获得音译文档。 I was trying to write this code using for loop insdie for loop, but I don't know how can I loop the whole document word by word... and at the same time rewrite the new form of word instead of the currently taken word. 我试图使用for循环编写此代码insdie for loop,但我不知道如何逐个单词循环整个文档...同时重写新的单词形式,而不是当前的单词。

Please, help me with right Interop.Word commands to implement this. 请帮助我使用正确的Interop.Word命令来实现此目的。

This article explains how to retrieve words from a word doc 本文介绍了如何从Word文档中检索单词

http://zirmandli.wordpress.com/2007/07/04/read-word-doc-using-c/ http://zirmandli.wordpress.com/2007/07/04/read-word-doc-using-c/

Document is retrieved by calling this : 通过调用此文件来检索文档:

Word.Document doc = wordApp.Documents.Open(ref file, ref nullobj, ref nullobj,
                                      ref nullobj, ref nullobj, ref nullobj,
                                      ref nullobj, ref nullobj, ref nullobj,
                                      ref nullobj, ref nullobj, ref nullobj);

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

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