Word error on opening .dotx or .dotm

J

jallin

I am using Word 2007. I have created a form that has macros. When a
user saves the form using a command button a Save As macro runs which
password protects and saves the form as a .dotm file on a server. When
the user tries to open the form from the server they get an error "The
Office Open XML file (filename) cannot be opened because there are
problems with the contents". When they click "Details" it says "No
error detail available".

I have changed the code to save as a .dotx and a .dotm and both
produce this error. I have changed it to a .doc and it opens fine
without the error. Is there some way that I can fix this so users can
reopen the .dotm files?

Any help would be greatly appreciated.
 
T

Tony Jollans

I'm a bit lost as to whether you are using Documents or Templates, with or
without macros but if you are saying that you can create something with Word
2007 which other users of Word 2007 cannot open, I would be very interested
in seeing both it, and the code that creates it.
 
J

jallin

I have a form that was created in Word 2003. I changed the saveas code
(.doc to .docm) when we switched to 2007 but the form itself remained
the same. It has only one command button (activeX control) to save it
as a macro enabled document to one of our servers. It appears to save
fine. When I go to the server and double click to open it I get the
error "The Office Open XML file (filename) cannot be opened because
there are problems with the contents". When I click "Details" it says
"No error detail available".

Here is the code that I am using:

Set oDoc = ActiveDocument

'Unprotect the document
oDoc.Unprotect Password:="password"

oDoc.Fields(18).Select
fld = Selection

UsrIntls = Application.UserInitials

'Re-protect the document
oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:="password"

PathAndFileName = "N:\Lost Sale Reports\" & fld & "-" & UsrIntls &
""

'checks to see if a file by this name already exists?
If Dir(PathAndFileName & ".docm") = "" Then

oDoc.SaveAs (PathAndFileName & ".docm"),
fileformat:=wdFormatXMLDocumentMacroEnabled

Else
'yes a file by this name exists so add a number and check
again
n = 1
Do While Dir(PathAndFileName & "-" & n & ".docm") <> ""
n = n + 1
'still a file exists by this name so go back and try the next
letter
Loop
'now the file name is unique so save as indicated
oDoc.SaveAs PathAndFileName & "-" & n & ".docm"
End If

I'm sure this is something very simple but I just can't figure out
what it is. Thanks for any and all assistance.
 
T

Tony Jollans

My first thought is that you are saving as a docm when your document
probably doesn't contain macros. A quick test, however, showed that this is
possible - but maybe not in all circumstances. Does your document contain
mnacros? And, if not, does it work better if saved as a docx?
 

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