"The Office Open XML file <File Name> cannot be opened..."

A

Ailish

I'm struggling to resolve a problem that only crops up now and then. I'm
using Word 2007.

I have inserted a LastSavedBy field into a .docm file because I need to have
a (hidden text) record of which person last updated the contents of the file.
I have set that text as "Hidden" because I don't want it to get printed out.

Everything seems to go fine for a few updates but eventually the following
message appears when a user tries to open the most recent file to update it:

"The Office Open XML file "File Name" cannot be opened because there are
problems with the contents.

Details
Unspecified error
Location: Part: /word/document.xml, Line:2, Column: 202617"

It doesn't seem possible to predict when this message will appear, i.e. it
doesn't seem to happen after a particular number of updates or anything.

The Location always indicates Line2 which is where the LastSavedBy field is
and deleting that field is the only thing that ever resolves the problem -
but that leaves me without a record of who performed the update.

The .docm file is attached to a .dotm template.

In the past, I tried using a content control and running the macro below
when the user saved and closed the file. It worked fine for one update but
after that it gave rise to a similar message (different Details though).
Internet searches taught me that Word 2007 can't cope with having a field
inserted inside a content control.

Sub SavedBy()
Dim ccSavedBy As ContentControl
Dim strUserName As String
Set ccSavedBy = ActiveDocument.SelectContentControlsByTitle("Saved
By").Item(1)
'ccSavedBy.SetPlaceholderText Text:=" "
strUserName = Application.UserName

'ccSavedBy.Range.Text = strUserName
End Sub


Can anybody see what I'm doing wrong with the LastSavedBy field? Or offer
an alternative method of automatically recording who saves a file?

Thanks for any advice
Ailish
 
T

Tony Jollans

You are doing nothing wrong.

Unfortunately this happens sometimes. One of the big problems of using a new
format file is that all the code for it is new and has bugs. There are
circumstances where Word cannot read files it has written; most often I have
seen this with TOCs in largish documents, but it also happens in other
circumstances. If you have anything approaching a repeatable situation where
it occurs I would be interested in knowing more. It probably has nothing to
do with your hidden text.

Word seems to go out of its way to make recovery awkward; one way it does
this is by having a ridiciulously long line. It is possible to find out what
is at position 202617 on line 2 (almost certainly an end tag of some sort)
but it probably won't help in finding what is actually wrong with the file.
It is also possible to find whatever is in your hidden text but you don't
say how you are recovering so it is difficult to know what best to suggest -
are you somehow maintaining your updates but losing the identity of the
person responsible, or what?
 
A

Ailish

Hi Tony,

Thanks for your reply.

Regarding recovery: The error message has an OK button. When that is
clicked, another message is generated.

"Word found unreadable content in <File Name>. Do you want to recover the
contents of this document? If you trust the source of this document, click
Yes."

When you click Yes, Word then opens and repairs the document.

I just opened one of the problem files to read an replicate that message.
In doing so, I've discovered that this time the repair resolved the problem
without having to delete the LastSavedBy field. On past occasions, the
problem "travelled" with the subsequent document despite the repair on
opening. By that I mean that when that update (document) was saved and then
opened by the next user, the same error message would appear. But that may
have been when I was using the field within the content control, I'm not
sure. In the meantime I've been assuming it would travel every time unless I
did something about it (deleting the field) and that clearly isn't the case
now. I can live with it appearing once and going away - if it stays that
way! Hopefully the users will cope with it too.

Thanks for your help.

Ailish
 
T

Tony Jollans

Thank you Ailish.

If you have an example of a document that gives an error, but Word will
repair it, and then propagate the error when you save again, I would
certainly be interested in seeing it (if it's not confidential).

I'm not a fan of the new format (I was, initially, but have changed my
mind), but when Word says it has managed to recover/repair the document I
tend to believe it - most of the time it fails, and I suspect Word plays
pretty safe in claiming success.

If you get this, shall we say, minor corruption, on occasion and are always
successful in recovering you may be able to live with it, but you shouldn't
have to, and if it happens regularly on a particular document there must be
something in that document that triggers it (not anything you have done
wrong, but some particular combination that triggers the error in Word).
Again, I would be interested to see such a document. What would worry me
would be the occasion when Word could no longer cope, and you lost your
updated document completely - this kind of corruption can usually be dealt
with manually if you know enough about the internals, but it's not a job for
normal mortals. It sounds like you keep plenty backups so it might not be
disastrous for you; nonetheless it would be better pre-empted if possible.
 
H

Holly

If all else fails, you can try what I stumbled upon.
I emailed my husband a copy of the docx file that wouldn’t open, thinking he
could try opening it in Office 2003. That didn’t work.
But since it was a gmail account, he then tried using Google documents or
opening it as an html document, both of which worked, however the formatting
isn’t the same as the original.
But if you just want to recover text to paste in a new document, using
gmail/google documents might help you out!
 

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