Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to replace text parts of Sentences. my approach is
Iterate on Sentences , since I use like this Document.Sentences.Count;
then I replace then in two way.
if Sentences is only includes text, I replace whole Sentences as below
MIDL
Range rng = Sentences[i].Range(Start,End);
rng.Text = str ;
rng.Select;


if Sentences includes pictures, OLE object and ActiveX so on.
I extract the pure text part and apply above code to replace it.and the start and end position of text part is correct, I checked it.

problem is that when I replacing parts of Sentences it throw "Cannot delete Range " exception.
how can I do this if I want replace text part of Sentences which includes both text and picture?

thanks!
Posted
Comments
Apfelmuuus 24-Mar-11 6:01am    
I can't figure out what is the problem because I do not know how you want to replace "parts of Sentences"

One possible problem can be found at msdn:

"Note Range objects are independent of the selection. That is, you can define and manipulate a range without changing the selection.[...]"MSDN
jk0391 28-May-15 15:27pm    
Post your entire code snippet you've tried. You are telling us you have this "if" case and that "if" case but it is not provided...

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