How to find a corrupted table

B

Bruno

I'm working on a document with many tables, when i open it i get a warning that one of the tables has become corrupt. How do i find which one has the problem?
 
S

Shauna Kelly

Hi Bruno

Brute force is the only method. Make a backup copy of your document and
tuck it away safely before you begin.

Now, make a copy of the document. Delete the top half, save, close and
re-open the file. Do you still get the error message? Yes? Then the
problem is in the bottom half of the document. Delete half of that,
save, close and re-open. Repeat until you discover the problem table.
Unless you have hundreds and hundreds of tables, this method is quicker
than you might think.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Melbourne, Australia


Bruno said:
I'm working on a document with many tables, when i open it i get a
warning that one of the tables has become corrupt. How do i find which
one has the problem?
 
B

Bruce Brown

Bruno

This macro borrows the save/reopen technique that Shauna suggests here
but does so for each table in the document. For not many tables,
Shauna's method has to be faster; for a whole lot of tables and/or
multiple corrupt tables, this one's probably easier.

It cycles through each table in the document. When it finds a corrupt
one (with your help) it applies double strikethrough to the table so
you can see it. Then you go back and reconstruct or re-do the
offending table(s).

* First save a blank doc as "TestTables.doc" and put it in the
same folder as your original doc. If you're on a network, it may mean
putting both of them on the C:\ drive temporarily.

* Then paste this macro into your original doc (not into
Normal.dot). Use these steps:

1) Copy the code below from the thread
2) On your original doc, Alt-F8
3) In Macros box, select the original doc name
4) In the Macro name box, type in "TestTables"
5) Click Create, which takes you straight into the code editor
6) Paste this code into the editor between Sub TestTables () and End
Sub
7) Where you get two red lines, put them back together into one line
with an extra space where the line break was
8) To run the macro, Alt-F8, select "TestTables", click Run

* No guarantees here because I had no corrupt tables to test
with.

* Would appreciate it if someone with corrupt tables tested it and
came back to let us know if it works or not.

Dim T As Table, Cnt As Integer, Ans As Byte, TCnt As Integer
TCnt = ActiveDocument.Tables.Count
For Each T In ActiveDocument.Tables
Application.ScreenUpdating = False
Cnt = Cnt + 1
T.Range.Copy
Documents.Open "TestTables.doc"
ActiveDocument.Content = ""
Selection.PasteAndFormat (wdPasteDefault)
ActiveDocument.Save
ActiveWindow.Close
Documents.Open "TestTables.doc"
Application.ScreenUpdating = True
Application.ScreenRefresh
Ans = MsgBox("Is table #" & Cnt & " corrupt?", vbYesNoCancel, _
"Table #" & Cnt & " of " & TCnt)
If Ans = 2 Then
MsgBox "Quitting."
ActiveWindow.Close wdDoNotSaveChanges
Exit Sub
End If
Application.ScreenUpdating = False
ActiveWindow.Close
If Ans = 6 Then
T.Range.Font.DoubleStrikeThrough = True
End If
Next

If you want to replace the DoubleStrikeThrough with a color or a
highlight, you could record a simple macro that changed the color of
selected text, then plop that code into the third line from the
bottom. Instead of 'Selection.Font' use 'T.Range.Font' as you see
above.
 
D

David

This didn't work... at all

----- Bruce Brown wrote: ----

Brun

This macro borrows the save/reopen technique that Shauna suggests her
but does so for each table in the document. For not many tables
Shauna's method has to be faster; for a whole lot of tables and/o
multiple corrupt tables, this one's probably easier

It cycles through each table in the document. When it finds a corrup
one (with your help) it applies double strikethrough to the table s
you can see it. Then you go back and reconstruct or re-do th
offending table(s)

* First save a blank doc as "TestTables.doc" and put it in th
same folder as your original doc. If you're on a network, it may mea
putting both of them on the C:\ drive temporarily

* Then paste this macro into your original doc (not int
Normal.dot). Use these steps

1) Copy the code below from the threa
2) On your original doc, Alt-F
3) In Macros box, select the original doc nam
4) In the Macro name box, type in "TestTables
5) Click Create, which takes you straight into the code edito
6) Paste this code into the editor between Sub TestTables () and En
Su
7) Where you get two red lines, put them back together into one lin
with an extra space where the line break wa
8) To run the macro, Alt-F8, select "TestTables", click Ru

* No guarantees here because I had no corrupt tables to tes
with

* Would appreciate it if someone with corrupt tables tested it an
came back to let us know if it works or not

Dim T As Table, Cnt As Integer, Ans As Byte, TCnt As Intege
TCnt = ActiveDocument.Tables.Coun
For Each T In ActiveDocument.Table
Application.ScreenUpdating = Fals
Cnt = Cnt +
T.Range.Cop
Documents.Open "TestTables.doc
ActiveDocument.Content = "
Selection.PasteAndFormat (wdPasteDefault
ActiveDocument.Sav
ActiveWindow.Clos
Documents.Open "TestTables.doc
Application.ScreenUpdating = Tru
Application.ScreenRefres
Ans = MsgBox("Is table #" & Cnt & " corrupt?", vbYesNoCancel,
"Table #" & Cnt & " of " & TCnt
If Ans = 2 The
MsgBox "Quitting.
ActiveWindow.Close wdDoNotSaveChange
Exit Su
End I
Application.ScreenUpdating = Fals
ActiveWindow.Clos
If Ans = 6 The
T.Range.Font.DoubleStrikeThrough = Tru
End I
Nex

If you want to replace the DoubleStrikeThrough with a color or
highlight, you could record a simple macro that changed the color o
selected text, then plop that code into the third line from th
bottom. Instead of 'Selection.Font' use 'T.Range.Font' as you se
above
 
B

Bruce Brown

David, thank you for testing the macro; I had no corrupt tables to test it on.
Sorry to get your hopes up, but now we know. - Bruce
 
B

Brad R.

I tried your macro, Bruce. It ran through like the first ten tables and then I got a Visual Basic error. I can't tell you what the error was, because now the macro has been disabled, and I don't know how to re-enable it.

So then I tried Shauna's brute force method. Here's an interesting development: I removed all of the tables in a document, saved it, and the Corrupt Table message still appeared.

Any other suggestions you guys have would be appreciated. Thanks for your help.
 
S

Shauna Kelly

Hi Brad

Before you try any of the following, make a backup copy of your document
and put it away safelly in case you need to go back to it.

Try saving the document as a Web document (*not* filtered), then close
that file and re-open it (as an ordinary Word document). If that doesn't
work, try a similar round-trip through RTF.

And, see
How can I recover a corrupt document or template - and why did it become
corrupt?
http://www.mvps.org/word/FAQs/AppErrors/CorruptDoc.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Melbourne, Australia


Brad R. said:
I tried your macro, Bruce. It ran through like the first ten tables
and then I got a Visual Basic error. I can't tell you what the error
was, because now the macro has been disabled, and I don't know how to
re-enable it.
So then I tried Shauna's brute force method. Here's an interesting
development: I removed all of the tables in a document, saved it, and
the Corrupt Table message still appeared.
Any other suggestions you guys have would be appreciated. Thanks for
your help.
 
B

Brad R.

My God, I think it worked! (That is, saving to .htm and then back to doc.) Thanks a million, Shauna!
 
M

mauvehillgus

In a customer environment they are using Microsoft Office 2000
Professional SR-1 (mostly, but not all SP3 for Office)

I have a problem similar to the above - the difference being that when
I try to "manipulate" the document in any way Word stops responding -
and eventually shuts down.

I have tried renaming the files and opening them as .rtf, .htm, Word
6.0 format etc. - all to no avail.

I have also tried opening the documents on machines running XP SP1, W2K
SP4, SP3 and SP2.

On the W2K machines I get a Dr Watson error after opening the
document(s), and on the XP machines I get the standard XP error message
which asks me whether or not I want to send an error report to
Microsoft.

Has anyone got -any- suggestions as to how I can rectify this issue? -
short of restoring an earlier (and way out of date document - which may
in time become corrupt itself)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top