Share via

Content controls losing its formatting when used in a table cell inside a repeating content control in Word 2013

Anonymous
2013-09-13T13:30:18+00:00

Hi guys,

I'm using content controls since they were introduced in Office 2007 and found them very helpful when it comes to automatic document creation, especially with custom XML data and appropriate data bindings. I handled repeating sections myself through custom code and it worked fine, though it was quite complex in the beginning. It's now the first time that I'm playing with the repeating content control in Word 2013 and it works perfectly regarding the data. However, the formatting is driving me nuts.

I have a table with two rows and six columns. The first row contains the headers (just text) and the second the data, using six content controls, one per column and all of them being plain text controls. The text in colums 1, 4, 5 and 6 aligns to the right. The font style in column 1 is italic and in column 2 its bold.

I'm using a repeating content control around the entire second row and bound it to an XML element in a custom XML part. This element can occur multiple times and thus the table may have multiple data rows. The custom XML part is replaced with real business data through a .NET application. Everything works fine except for the formatting. The first colum is properly aligned to the right and uses the italic font style. The second column, however, only displays the first data row in bold. Subsequent rows are usingt a regular font style. And columns 4, 5 and 6 are aligned to the left, instead to the right.

The same happens when adding a new row to the data bound table in Word itself. After the repeating content control is bound to a repeating XML element, we can click on the plus sign right to the last column to insert a new row, which also adds a new element to the XML stored in the custom XML part. The newly inserted row shows the same behavior (wrong alignment, wrong font style). It makes no difference if I'm using plain text controls or rich text controls. I even marked the entire document and set the text alignment to right, but the text alignment is always wrong as described before. The styles are persisted if the repeating content control does not repeat a table row, but that doesn't help.

Before trying to fix it programmatically I wanted to know if someone knows a solution or workaround.

Thanks in advance,

Michael

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2013-09-14T16:50:09+00:00

By experiment, it appears that the repeated rows don't carry along directly applied paragraph formatting, including alignment and line spacing. However, if you define and apply a paragraph style to the cells containing the content controls, that style will be repeated in added rows.

So for this instance, define a paragraph style (named something like Right Align) that's the same formatting as Normal except for right alignment, and apply it to the cells in columns 4, 5, and 6 (and maybe column 1 for good measure). It would probably also be advisable -- as a preventive measure -- to apply the Emphasis character style in place of direct italic format, and the Strong style in place of bold.

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2013-09-17T13:26:58+00:00

    Perfect, thanks a lot. Using styles the content now is properly formatted. 

    Michael

    Was this answer helpful?

    0 comments No comments