Debugging Word Formatting – Unexpected Table Indents

Following on from Case of the Corrupted Word Formatting Here https://chentiangemalc.wordpress.com/2013/05/21/case-of-the-corrupted-word-formatting/

So I had this table in Word 2013 like so:

image

However while editing something not obviously related in the document indents appeared:

image

I could “delete” the indent with a backspace key, but even showing special characters, there didn’t seem to be anything obvious there (like a TAB character which would have shown up as a right arrow)

Most of the time this could be fixed by “cutting” the table then pasting it, and selecting merge formatting option. In some cases this didn’t fix the formatting, and it required a paste into excel, then copy paste back into Word.

image

So I created two .docx just with the one table in it-  one with the bad format, one with the “merge formatting” fix. To ensure documents were as similar as possible I created the first document, pasted bad table, saved my “bad docx”, then cut the table from same document, pasted it with merge settings in same location as previous table, and saved as “good docx”

I then renamed both .docx to .ZIP and extracted their contents.

I compared the extracted folders in Beyond Compare, initially i only compared file sizes, as word embeds time/date stamps in many files that I didn’t want to compare.

The most obvious document was documents.xml, I opened up each \word\documents.xml file in PSPad Editor and applied HTML Reformat HTML code to make them easier to read:

image

We could than easily see difference in Beyond Compare:

image

In the “good” version we had

<w:spacing w:after=”160″ w:line=”259″ w:lineRule=”auto”/>

In the “bad” version we had

<w:pStyle w:val=”ParaText”/>

So I suspect w:val=ParaText the root cause of our issue…

So for first fix I tried removing it for the one cell:

image

I saved the XML and re-zipped the contents, renamed back to .DOCX:

Sure enough one cell was fixed:

image

We can see this when we search ParaText in Word\Styles.xml from an extracted DOCX.

<w:style w:type=”paragraph” w:customStyle=”1″ w:styleId=”ParaText”>
<w:name w:val=”Para Text”/>
<w:link w:val=”ParaTextChar”/>
<w:rsid w:val=”00FC1EAB”/>
<w:pPr>
<w:keepLines/>
<w:spacing w:before=”60″ w:after=”60″ w:line=”240″ w:lineRule=”auto”/>
<w:ind w:left=”1134″/>

</w:pPr>
<w:rPr>
<w:rFonts w:ascii=”Arial” w:eastAsia=”SimSun” w:hAnsi=”Arial” w:cs=”Times New Roman”/>
<w:sz w:val=”20″/>
<w:szCs w:val=”24″/>
<w:lang w:val=”en-AU” w:eastAsia=”en-US”/>
</w:rPr>

One way to fix this would be to select all text in every table on every page in the document and set to “Normal Style””

image

However in a 300 pages+ word document, that seemed like a hassle.

So I put cursor on some affected text, then selected Apply Styles…

image

This brought up an Apply Styles window. Notice how the original style view didn’t show this style name at all? I think we found our Para Text

image

I then modified the paragraph format option:

image

And reset the left indent from 2cm to 0cm

image

Now all the tables in document were fixed

image

My paragraphs may be missing indents, but at least the tables are readable…

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s