Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

1 solution

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();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900