Free Support Forum - aspose.com

How to Manipulate the syles of existing text in a word doc

Hi All,

I just want to know how to manipulate the styles of text for a existing word document. My requirement is i want to change the format of word document programatically.(i.e) I want to read a word document containing some data. I just want to change the font color, Font name, Replace the text of paragraph etc.....

I had gone through the API and some articles but i have not succeeded in finding any article or code related to my requirement.

Thanks and Regards

Font settings for the text are controlled by Run.Font properties. Paragraph formatting is controlled via Paragraph.ParagraphFormat property.

To apply a particular style to a run of text set Run.Font.StyleName property.

To replace text of the paragraph use Paragraph.Range.Replace method.

Here is an example showing how to change the color of the document text.

NodeCollection runs = doc.GetChildNodes(NodeType.Run, true);

foreach(Run run in runs)

{

run.Font.Color = System.Drawing.Color.Red;

}

Hi miklovan,

I'm Very much thankful to you. Becoz it really helped me a lot.

Thanks and Regards

Mahesh Kumar. N