Corrupted document in MS Word2003

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Corrupted document in MS Word2003

Post by ChrisGreaves »

I clone documents. My latest MSWord document “W:\Tripping\Transit\GoTransit\KeswickForTheDay\Planning.doc” could well be a one-thousandth clone of an original document, since I have 5,347 DOCuments in my W(eb) folder. I compile documents to make web pages, so cloning a thousand times since, say, 1997 is possible.
I suspect that DOCuments get corrupted over time, just like those tellomere things on the end of our chromosomes, and just like VBA projects (which is why all smart VBA folks use Rob Bovey’s VBA Code Cleaner; regularly).

I was trying to sort a small table with hyperlinks to documents that are children of the parent “index.doc” and MS Word crashed and crashed and crashed ...
I don’t need a solution but I thought to post just to show far this corruption can go.
(And having said that I am now wondering if myForced Upper Case bug is caused by corruption in a few specific documents)
Can'tSort01.png
Here I was in the original document, minding my own business, dum-de-dum; I think I’ll sort this table (part of a three-page document) into ascending sequence. Table, Sort, Columnn1, Bang!
Can'tSort02.png
Nothing stops me! I reload MSW and delete all text before and after my table, thinking to isolate the problem. Sort. Bang!
Now, I know that the corruption my not be in my visible text; it is most likely in some part of the structure of the document, hidden to the user (me), nonetheless, I’m curious ...
Can'tSort03.png
Nothing stops me! I reload MSWord and in the empty “Document1” I paste my table, which has been copied to the clipboard.
Kapow!
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

ChrisGreaves wrote:I clone documents....
Can'tSort04.png
Nothing stops me! I reboot and try again, Load MSWord, copy the table to the clipboard, exit MSWord, Reload an empty document, paste in the table.
Booom!
Can'tSort05.png
Closely followed (after I choose “Yes” from the screen above) by Zpazam!
Can'tSort06.png
Nothing stops me! I open Notepad and paste the table, just to get some plain ASCII text.
I convert the text to a table and try to sort.
No hyperlinks.
Nothing up my sleeve.
This stops me, at last.
I make a cup of tea and go for a lie-down (grin!)
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Corrupted document in MS Word2003

Post by macropod »

Did you try converting the tables to text & back again, or saving them in RTF then back again? A basic 'table repair' macro is:

Code: Select all

Sub TableRepair()
'Macro to repair damaged tables by saving each table in an RTF-format file, then
' copying & pasting the table from the RTF-format file back to the source document.
Application.ScreenUpdating = False
Dim Rng As Range, i As Long, RTFDoc As Document
With ActiveDocument
  For i = .Tables.Count To 1 Step -1
    MsgBox .Tables(i).Style
    Set Rng = .Tables(i).Range
    Rng.Cut
    Set RTFDoc = Documents.Add(Visible:=False)
    With RTFDoc
      .Range.Paste
      .SaveAs2 FileName:="RTFDoc.RTF", Fileformat:=wdFormatRTF, AddToRecentFiles:=False
      .Close
    End With
    Set RTFDoc = Documents.Open(FileName:="RTFDoc.RTF", AddToRecentFiles:=False, Visible:=False)
    With RTFDoc
      .Tables(1).Range.Copy
      .Close
    End With
    Rng.Paste
  Next
End With
Kill "RTFDoc.RTF"
Application.ScreenUpdating = True
End Sub
Paul Edstein
[Fmr MS MVP - Word]

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

macropod wrote:Did you try converting the tables to text & back again, or saving them in RTF then back again? A basic 'table repair' macro is:...
Hey Macropod! Welcome back, and I think THREE Happy Birthdays (that I have missed) :grin:
Thanks for the Macro, Pod;
I already have a neat TableRebuild macro (slave function below) which I use from time to time, but I'd probably write a self-contained document-rebuild thing that would take care of all content (text, images, hyperlinks) and layout/format (styles etc.) because I suspect that document corruption is capabale of seeping into every part of some documents.

Code: Select all

Public Function tblTableReBuild(tbl As Table) As Table
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''' Function:   tblTableReBuild
    '''
    ''' Comments:   Convert a table to text and back again.
    '''
    ''' Arguments:  TABLE       A table in a document.
    '''
    ''' Returns:    TABLE
    '''
    ''' Date        Developer       Action
    ''' --------------------------------------------------------------------------
    ''' 2007/01/18  Chris Greaves   Created
    '''
    tbl.Select
    Selection.Rows.ConvertToText Separator:=wdSeparateByTabs, NestedTables:=True
    Selection.ConvertToTable Separator:=wdSeparateByTabs, Format:=wdTableFormatNone
    Set tblTableReBuild = Selection.Tables(1)
End Function
Anyway, good to see your happy avatar again ... :cheers:
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

2015/09/18 10:49CG8721: What do 8706-8720 tell me? (1) 8706 suggests that the trigger does not lie in the path or name, since creating a new “Planning” did not trigger. (2) 8707 suggests the same thing, and that it might be the content. (3) 8716 however suggests that neither the name nor the content triggers. (4) 8717 suggests the trigger lies in the content, but after the content is reduced (by Cut) the trigger remains. (5) 8718 suggests that MSW “remembers” the path that triggered the bug. (6) 8719 (Creating a new document in the same folder but with a different name (“Executable” rather than “Execution”) triggers the bug) suggests that MSW “remembers” the path that triggered the bug. (7) 8720 (working from a different folder) suggests that (a) the trigger is associated with the folder name but that (b) working from an alternate folder causes MSW to “forget” the trigger in the original folder. Now, it may not be MSW that remembers the trigger; it may be some part of the Windows OS that gets corrupted as a result of a call from MSW and needs to be flushed out occasionally
I've not been goofing off, Honest!
The row above is the latest row in my "WhatFAQ.doc" which I use to chronicle a project.
I inch closer to limiting the cause of the trigger of the bug.

I am using as my testbed a document "W:\Tripping\Transit\GoTransit\OrangevilleForTheDay\Execution.doc", hence the references to different paths/folders and a change of name from "Execution.doc" to "Execution.doc".

Each session I experiment to see what can be done to dislodge the buggy situation, then I go home and fret/mull for a few hours ...
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Corrupted document in MS Word2003

Post by macropod »

Have you tried repairing the Office installation (Help|Detect & Repair), in case the problem relates to its VBA files?
Paul Edstein
[Fmr MS MVP - Word]

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

macropod wrote:Have you tried repairing the Office installation (Help|Detect & Repair), in case the problem relates to its VBA files?
Good thought, but yes, Macropod; I re-installed Win7HP/Office2003 back in, oh, August 5th or thereabouts, and triggered the bug with the basics.
That is, no updates.
I had previously triggered the bug with everything up to date.

OTOH I don't think I tried an explicit "Detect & Repair".
I'll give it a try, just to eliminate that as a potential source of trouble.
(We need a smiley :but I don't hold out much hope:)

I oscillate - or vacillate, I can never make up my mind - between believing that the trigger is due to something in my files/documents and the belief that it is related to the age of Office2003 program code in some sort of conflict with Win7 program code. :hairout:
He who plants a seed, plants life.

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

Re: Corrupted document in MS Word2003

Post by kdock »

Chris, how is cloning different than copying? Other than the spelling?
:bananas:
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

kdock wrote:Chris, how is cloning different than copying?
Hello Kdock!
When I say that I have copied a document I usually mean that I have selected the contents and copied them to the clipboard, then created a new document (typically File, New) and pasted into the new document from the clipboard. I thus have two DOCuments open on my computer.

"Cloning" to me means that I have a document open and then File, saveAs with a new name.

In development of web pages (which is why I am using a web compiler) I typically have a set of pages that belong in the same folder.

"W:\Home\2015\20150920Sun.doc" is such a document.

To develop a page the next day, I open "20150920Sun.doc" and immediately save it as "20150921Mon.doc", creating a newly-named document from an old one.
I am lazy (also I run most things under program control) so I do a lot of cloning.
(Imagine a macro that detects that I have just opened "20150920Sun.doc" on Monday 21st and automatically assumes that since "20150921Mon.doc" does not exist I must be creating a new diary entry and so automatically saves the document with an new name ...)

I hope that makes sense.

P.S. Your comment on spelling made me think that I had committed yet-another-typo! :guilt:

Cheers Chris
He who plants a seed, plants life.

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

Re: Corrupted document in MS Word2003

Post by kdock »

Since you like to do things automatically, have you thought of creating a macro that opens your previous day's document as if it were a template, thereby creating neither copy nor clone, but a brand new document? I recognize this is like your copy, but maybe a little easier? Or perhaps you've automated the copy and paste?

Just sayin'
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

kdock wrote:Since you like to do things automatically, have you thought of creating a macro that opens your previous day's document as if it were a template, thereby creating neither copy nor clone, but a brand new document? I recognize this is like your copy, but maybe a little easier? Or perhaps you've automated the copy and paste? Just sayin'
Hi kdock.
No, and no, respectively.
(but I have now :evilgrin: )
I am a creature of habit and display a tendency to get set in one mode of operation, and that's it.
But I'm a man; I can change.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

The most recent (past week) incidents led me to think that, perhaps, the Document Object is only returning what it has been given.

If a document is opened with a particular FullName, then, perhaps, the Document Object returns that FullName.
If a document is opened with a particular Uppercase FullName, then, perhaps, the Document Object returns that Uppercase FullName.
If a document is opened with a particular Camel case FullName, then, perhaps, the Document Object returns that Camel case FullName.

Suppose I open a document from the MRUse list and that list has somehow held the name in uppercase, then the Document Object might return an uppercase FullName, and hence WbWrd would obtain an Uppercase path.

Suppose I open a document from MSW’s File list and that list has the FullName in Title case, ...
Suppose I open the document from a Windows Explorer pane?

Why then not fabricate a Simple Test that offers various casings of the FullName to the Document Open command and observe what the Document Object reports back to me (in VBA)?

For those who have trouble dropping off to sleep at night or are concerned about their use of chemical sleeping aids, I have attached a nine-page PDF file.
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Corrupted document in MS Word2003

Post by ChrisGreaves »

Initially just an annoyance, I tried to dismiss this as a quirk of nature. Then it became too common an occurrence.
I was raised/trained to believe that every error is caused by the programmer. In nearly 50 years of programming there has been only one real exception – a hardware flaw in a CDC 3300 computer back in 1969-70.
Then Microsoft came along, and with it Microsoft Office.
Still I believed that in the absence of any reports (that I could find) of this problem on the web, the answer must lie in my program code.
But then – I make use of (“steal”) copies of other people’s code, and today the boundaries between code that is written by Microsoft, code that is purchased by Microsoft from a 3rd party, code borrowed from other programmers examples, and my original coding are blurred.
Perhaps it is not me, but the fault of half-a-dozen programmers whose code I blindly admire and accept; perhaps it is the fault of the thousands of programmers who have done time at Microsoft? Or there again it might be a blip in the free WiFi service or even (but unlikely) my web host (HostGator) All of which brings me full-circle to a quirk of nature.

My application MRUse was completely rewritten between March and July 2015, but still remained the most likely suspect. Various manifestations of the bug had me believing that MRUse was somehow causing Microsoft Word to flip a bit somewhere in Windows!

In the end I trusted a process of “loading the brain up with lots of data ad letting it ferment” over a period of about eight weeks.
I am indebted to Rick Groszkiewicz for supplying me with answers to many questions and loads of samples of apparently corrupt FullNames.

The solution came to me during the first four movements of Charles Marie Widor’s Symphony No. 5 during Wednesday’s free noontime concert. I jotted down my notes in time to lean back and relax as Simon Walker blasted out the Toccata.

This has been the most elusive bug I can recall in my undistinguished career.
I am glad it is over.
The bug, that is!
[Lounge Moderators: So Are We!]
He who plants a seed, plants life.