Hello,
I want to define a paragraph style and use it to format a paragraph in the generated Word document. Here is the code I use:
Document Doc=new Document();
Doc.EnsureMinimum();
Style newStyle;
newStyle=Doc.Document.Styles.Add(StyleType.Paragraph, "testStyle");
newStyle.Font.Name="Arial";
newStyle.BaseStyle="Normal";
//The following line makes the "testStyle" style disappear in the generated doc
//newStyle.Font.Bold=false;
newStyle.ParagraphFormat.Alignment=ParagraphAlignment.Right;
DocumentBuilder db=new DocumentBuilder(Doc);
db.ParagraphFormat.StyleName="testStyle";
db.Writeln("test text");
Doc.Save(@"c:\test.doc");
When I uncomment the lines that sets the ‘bold’ property in the ‘font’ object of the ‘testStyle’ style object, and regenerate the document: the generated paragraph does not have any style defined, and none of the formatting I specified in the ‘testStyle’ style were applied.
Can you reproduce this ? If yes, is my code wrong ?
I use Word 2003 to view the generated documents (they are generated in the .doc format).
The same behavior occurs if I set the ‘Color’ property instead of the ‘Bold’ property (I did not try any other properties, but I guess this happens for all properties of the ‘Font’ object)