开发者

End of page in C# Word plugin

I am writing a Word plugin to read all text in a document and saving it to a text file.

The text file generated will be used by another application of mine, and so I need to mark the end of every page's text by a '\f' character. My current logic merely saves the file though word as a plain text file, by using

object format = WdSaveFormat.WdFormatText;
...
Application.ActiveDocument.SaveAs( ..., ref format, ... );

The best method I found to insert a break was using ActiveDocument.Selection.InsertBreak().

开发者_JAVA百科Is there some way to determine the positions of page breaks in the original Word document so that I know where to insert the '\f' character?


This is one of the hard way to do it

use computestastics() for line number and get the no of lines

use goto to goto last line in the documnet and insert a Hard EOF

ex: Selection.GoTo(wdGoToLine,wdGoToAbsolute,4)


The only thing that I can think of right now is for you to save it as an html which will give you a

tag for every paragraph. Then you can get the begining of each paragraph text and used that to find the first starting position of each paragraph on the original document.

Also, you can do a Selection.Find and search for "^p" which is a paragraph mark.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜