HELP: Can't apply style programatically

D

Dan

I'm writing a C# app that allows exporting to a Word doc. I figured out how
to create the paragraphs and tables, and setting styles works from the code
perspective. However, when I open the document none of the styles are
applied. For instance, instead of a paragraph being "Heading 1", it will be
"Normal + 16pt" and similar for everything else. The strange thing is that if
I do exactly the same operations from JScript then it works fine. Does anyone
know what's going on here?!?

JScript (works)

par = doc.Content.Paragraphs.Add();
par.Range.Text = "Heading";
par.Style = doc.Styles("Heading 1");
par.Range.InsertParagraphAfter();

C# (doesn't work)

par = this.doc.Content.Paragraphs.Add(ref OptionalParam);
par.set_Style(ref style);
par.Range.Text = text;
par.Range.InsertParagraphAfter();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top