Click here to Skip to main content
15,892,697 members
Articles / Productivity Apps and Services / Microsoft Office / Microsoft Word

delete a line in word from VB.net

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Jan 2013CPOL 8.2K  
Hi, i'm looking for a function to delete one line from a word document. I want to do this from VB.net.I tried:Do While WordDoc.Content.Find.Execute(FindText:="%NP6%", Wrap:=Word.WdFindWrap.wdFindContinue) = True WordApp.Selection.Range.Bookmarks("\line").Range.Delete()Loop...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
1 Jan 2013Sander Rossel
What you're doing here is deleting lines while NP6% is still found in your document. Since you're deleting lines one by one it's no wonder all the lines up until the line with %NP6% are deleted. Once %NP6% is deleted the deleting will stop.Instead you should try looping through the Sentences...

License

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions