Word 2010: Heading corruption on print preview

Background

I have a large (279 page) document which has numbered and nested headings (i.e. '15.6' to '21.4.5.18')

Situation

When I either open the Print view form Backstage or highlight everything and press F9, both of which update all field values in the document, sections at the bottom of the document are moved to the top were they appear to be 'inserted' under other sections and the numbering / headings are jumbled.

(Unfortunately for confidentiality reasons I cannot post the actual document)

NOTE: This happens even when the contents are copied to an entirely new document and saved.

Question

How can I resolve this and stop it from happening ?

Has anyone had such a severe issue before ?
LVL 3
AL_XResearchAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul SauvéRetiredCommented:
This sometimes happened to me when I saved a .doc file as a .doc file OR using an existing file to continue creating a larger one.

Are the numbered/nested headings in your document defined as Heading 1, Heading 2, Heading 3, Heading 4, etc.?

Have you tried to copy smaller parts of the original document to a new Word file (i.e. first 10 pages, then add next 10 pages)? This may give you an idea from which point in the old document the problem actually starts.
DrTribosCommented:
Can you do a test print to PDF (just to rule out the possibility of a screen rendering issue)?
DrTribosCommented:
Try updating fields like this instead, and see if you get the same issue:
application.Visible = False
application.ActiveDocument.Fields.Update
application.Visible = True
application.ScreenRefresh

Open in new window

Should isolate any issue caused by screen display :-)
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

AL_XResearchAuthor Commented:
DrTribos: I tried you code but unfortunately the document still corrupts. Heading 20 moves up to Heading 2.10 and other sections also change place.

As I have said it is a very large document (280 pages) and even copying to a new document in batches of 10 pages will take a very long time. Don't forget that I have already tried copying the whole document to a new file with no change in the 'field update corruption'
AL_XResearchAuthor Commented:
I have tried printing to PDF also - no joy.

NOTE: To clarify, when I say the document corrupts I don't mean the contents page is messed up. I mean text from late in the document moves up to the much earlier position and the navigation pane reflects the change in heading order. The heading text is 'moved up' but the numbers are still in sequence so the section that was 20 and on page 148 becomes section 4 on page 22 !!

Any further suggestions would be most appreciated as this is now urgent !

(I would award 2000 points if I could !)
DrTribosCommented:
Thanks for confirming.  Well... it (MS Word) *should* work... of course it seldom does.  

How do you feel about writing a 'rescue' macro.  I'm thinking that some sort of corruption / inconsistency has crept into the document.  It might be using multiple styles for numbering.  

Without seeing the document (which I understand is confidential) it is only possible to speculate.  But... perhaps   create a new numbering scheme as outlined by the late and highly respected Word MPV aka dreamboat.

And then use a macro to rip through the document and reapply the new  style to your wayward headings...?
DrTribosCommented:
I don't actually have time to  write and test a macro... but the basic structure for find and replace is illustrated here: http://www.experts-exchange.com/questions/28856899/Add-'Comment'-to-a-word.html and there are many examples. and you can use find to match existing styles etc.

It would be interesting to find out if you have multiple style definitions competing with each other.

Hope this helps, good luck
AL_XResearchAuthor Commented:
bump
AL_XResearchAuthor Commented:
DrTribos: I am sorry to say those links do not seem to apply to the problem I am having.

It is not just the numbering / styles that is going wrong or anything but is physically moving blocks of text from one section to another and the re-flowing the heading numbering so that where you had the blow normal document

1 - A
1.1 AA
1.2 AA
2 - B
2.1 -  BB
3 - C
3.1 - CC
3.2 - CC
...
25 - Y
25.1 - YY
26 - Z
26.1 - ZZ

You now have

1 - A
1.1 AA
1.2 AA
2 - Y
2.1 -  YY
3 - C
3.1 - CC
3.2 - CC
...
25 - B
25.1 - BB
26 - Z
26.1 - ZZ

I have tried opening the file in 'repair' mode and it did not resolve the issue.

Since it appears to always be the same sections that move I tried to look at any hidden control codes by 'Show Paragraph marks' shows nothing new. I don't really know what I am looking for.
DrTribosCommented:
Oh. That sucks. Could you save as plain text and  run a macro through  it to rebuild the TOC??
AL_XResearchAuthor Commented:
Hmmm possibly but that would be my last resort since it would be hard for the macro to identify a specific piece of plain text should be a heading or not.

I must apologize - my question heading was a bit misleading - as I have explained it is not just the headings that get corrupted but also the text body.

Since the corruption always moves the same sections it suggests there is some corrupt field code or heading but only about 25 % of the sections move so the corruption can't be with the heading style itself. Is there any 'developer view' / 'field code view' I could look at for the headings ?

I have not fond any so far but hopefully you or another expert know more than me.
DrTribosCommented:
Alt F9 or Ctrl F9, i can't remember which,  toggles the field codes

Alt > i > k shows the bookmark dialogue
DrTribosCommented:
A macro could loop through the doc and print a list of fields, bookmarks, heading styles...

Dim oFld as Field
For each oFld in ActiveDocument.Fields
   Debug.Print oFld.Range.paragraphs (1).range.text
' might be ofld.code.range ....
Next oFld

Might be enough to get you started - using phone (& memory). No pc to test.
AL_XResearchAuthor Commented:
Interestingly  have just added so more pages (to make 277) and then updated the TOC and the document didn't corrupt !

When I update all fields (CTRL+A then ALT+F9) or open print preview (which updates all fields automatically) it still corrupts.

It definately used to corrupt when I updated the TOC.
DrTribosCommented:
When you say 'sections' do you mean 'section breaks' - document information should tell you how many sections there are.

Could some of the text be caught up in headers or footers?

Have you investigated with style explorer - perhaps there are multiple heading styles defined and they may sort differently.  

Just some ideas
AL_XResearchAuthor Commented:
I am sorry it has been so long since my last post.

I tried copying multiple sections at a time to a new document but the corruption remained.

In the end I had to copy each section one by one to a new document and saving and pressing CTRL+A and F9. With 300+ pages and over 40 sections it took all day but it worked ! Now the document is free from corruption.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Paul SauvéRetiredCommented:
I did suggest:
Have you tried to copy smaller parts of the original document to a new Word file (i.e. first 10 pages, then add next 10 pages)? This may give you an idea from which point in the old document the problem actually starts.
But, I did not explicitly say each section one by one...

No objection to closing the question! Feliz año nuevo :-)
AL_XResearchAuthor Commented:
Paul: As I say I tried to copy 10 pages a time but that turned out to preserve the corruption so I had to copy  smaller and smaller numbers of pages
AL_XResearchAuthor Commented:
This was the only solution that worked
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.