Hi
Are there any known issues with the use of DocumentBuilder.ParagraphFormat.StyleName?
I am using a template I created with the desired styles. However if I attempt to use any of the styles with DocumentBuilder.ParagraphFormat.StyleName in my code, the resulting Word document will not load. Word just hangs.
The example code below produces a usable Word document if the line setting the StyleName is commented out, but I get the problem described above if it is left in.
Aspose.Word.Word.SetLicense(this.Server.MapPath("Aspose.Office.lic"),this);
Document doc = new Document(MapPath("WordExtractTemplate.dot"));
DocumentBuilder b = new DocumentBuilder(doc);
// Set merge fields
b.MoveToMergeField("ExtractTitle");
b.Write("New Report");
b.MoveToMergeField("ExtractSubTitle");
b.Write("New Report Sub Title");
b.MoveToMergeField("PublicationDate");
b.Write("26/01/2005");
b.MoveToMergeField("Breadcrumb");
b.Write("Chapter 3: A New Template");
b.MoveToMergeField("ProductID");
b.Write("Prod1");
b.MoveToMergeField("FooterProductID");
b.Write("Prod1");
b.MoveToMergeField("StartExtract");
b.ParagraphFormat.ClearFormatting();
b.ParagraphFormat.StyleName = "Extract_Body";
b.Writeln("Some Example Text");
doc.MailMerge.DeleteFields();
doc.Save("testExtract.doc", SaveFormat.FormatDocument, SaveType.OpenInWord, this.Response);
I don't want to have to set all formatting attributes in code, as I'd like the flexibility to change them in the template in the future without touching the code.
I am using Word 2000 (9.0.6926 SP-3) to open the document, and Aspose.Word.dll file version 1.0.1850.31896. I'd be happy to send you the template I am using.
Any help appreciated.
Regards
Mike Cook