Question

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 = "";
Was it helpful?

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 = "";

Also Thank you to varocarbas :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top