Hi, i'm looking for a function to delete one line from a word document. I want to do this from VB.net.
Do While WordDoc.Content.Find.Execute(FindText:="%NP6%", Wrap:=Word.WdFindWrap.wdFindContinue) = True
Instead of deleting one row it deletes the complete first part of the document, including the line with %NP6%.
Anyone an idea, Thanks, Rob
Edited 1-Jan-13 10:23am
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 of WordDoc.Content and check the Text Property. If it contains %NP6% delete it.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)