I'm using c#.net and word 2007 lib's

I want to be able to grab a portion of the Word.Range.Text and change it without affecting the formatting, text or anything else in the Range.

How would I go about getting a portion of the Word.Range.Text so I can change the text or even just delete that portion of the text?

example:

I want this text edited/delete But this portion to be left alone

Solution: Ok, Turns out you need to have a "clone" of the paragraph and then by setting the start and end of the range within the cloned variable you are able to set where in the paragraph you want to edit. As follows:

Word.Range clonedRange = parag.Range;
cloneRange.Start = 0;
cloneRange.End = 15;

cloneRange.Text = "";
有帮助吗?

解决方案

Ok, Turns out you need to have a "clone" of the paragraph and then by setting the start and end of the range within the cloned variable you are able to set where in the paragraph you want to edit. As follows:

Word.Range clonedRange = parag.Range;
cloneRange.Start = 0;
cloneRange.End = 15;

cloneRange.Text = "";

Also Thank you to varocarbas :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top