I'm trying to create a Word document and I need a table of contents. I have different sized text and I tried to set their style according to the planned display. However, I get an exception when I try to call set_Style method. Why does that happen
Here is the code:
object styleHeading2;object styleHeading3;
in the calling method:
styleHeading2 = "Heading2";styleHeading3 = "Heading3";
in the called method:
WordApp.Selection.Range.set_Style(ref styleHeading2); //here is the exception: the element doesn't exist
The error code is: 2146822454
I checked, none of the object were null, so I don't get it why the exception is thrown. Any idea