Insert Nested STYLEREF Field inside TC Field in Word Document using C# .NET

Hi there,

I’d like to insert a TC field like the following -

var v = b.InsertField("TC { STYLEREF \"section-header\" }");

It doesn’t seem to understand the inner field and just seems to try and render it as text.

Am i missing something with the formatting? Or is there an alternative way of achieving this?

thanks!

Something about posting a question always seems to help focus the mind… I found that in this case I can use something like this to build the field incrementally

var v = b.InsertField("TC");
b.MoveTo(v.End);
b.InsertField("STYLEREF \"my-style-name\"");

@ykoorb,

It is great that you were able to find what you were looking for. Please let us know any time you may have any further queries in future.