如何使用C#,Interop.Word删除文件Word的最后一行? [英] How to delete the last line of file Word using C#, Interop.Word ?
本文介绍了如何使用C#,Interop.Word删除文件Word的最后一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我文件的最后一个文件是一个空白行。所以,我想删除这一行。
你知道如何使用Interop.Word吗?
谢谢和问候,
Tai
Hi everyone,
The last file of my file is a blank line. So, I am want to delete this line.
Do you know how to do that using Interop.Word ?
Thanks and regards,
Tai
推荐答案
嘿,
也许这段代码可能会有所帮助。
Microsoft.Office.Interop.Word.Paragraphs paragraph = null;
Microsoft.Office。 Interop.Word.Document wordDocument2 = _wordApp.Documents.Open(System.IO.Path.Combine(_shadowCopyDocumentFilePath));
paragraph = wordDocument2.Paragraphs;
if(paragraphs.Last.Range.Text.Trim()== string.Empty)
{
段落.Last.Range.Select();
_wordApp.Selection.Delete();
}
Hey,
Maybe this code can be helpful.
Microsoft.Office.Interop.Word.Paragraphs paragraphs = null;
Microsoft.Office.Interop.Word.Document wordDocument2 = _wordApp.Documents.Open(System.IO.Path.Combine(_shadowCopyDocumentFilePath));
paragraphs = wordDocument2.Paragraphs;
if (paragraphs.Last.Range.Text.Trim() == string.Empty)
{
paragraphs.Last.Range.Select();
_wordApp.Selection.Delete();
}
这篇关于如何使用C#,Interop.Word删除文件Word的最后一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文