PDA

View Full Version : SaveAs XML not working



slyguy
04-10-2014, 05:14 PM
Hi,

Have had a script in vb6, calling a save as word 2003 xml (wdFormatXML):

m_WordDoc.SaveAs l_snewfile2, wdFormatXML

This has worked fine I believe on literally 00,000's of files.

I was sent a file that its not working. The file the sent is a 159 page word file (.docx) file and it doesn't appear odd. The Save As box comes up, if you choose Word 2003 XML, and then click Save, the Save As dialog box disappears for a moment, and it reappears. It is stuck doing this.

Interestingly, if I change the call to Word XML Document:

m_WordDoc.SaveAs l_snewfile2, wdFormatXMLDocument

It saves fine, and the script completes.

I need to figure out why this is happening. Can you help me by providing things to look for in the document that may prevent saving as Word 2003 XML?

Thanks so much!

snb
04-12-2014, 03:02 PM
Has the Word version been changed (into 2007 , 2010 or 2013) ?

Paul_Hossler
04-12-2014, 03:27 PM
I looked in my Word2010 help file

Try SaveAs2. The Word constants are the same, but I've had issues sometimes with back-saving new Office documents




m_WordDoc.SaveAs2 l_snewfile2, wdFormatXMLDocument



Paul

slyguy
04-14-2014, 05:28 AM
I looked in my Word2010 help file

Try SaveAs2. The Word constants are the same, but I've had issues sometimes with back-saving new Office documents




m_WordDoc.SaveAs2 l_snewfile2, wdFormatXMLDocument



Paul

Unfortunately, saveas2 doesn't work. Frustrating. Any other ideas?

slyguy
04-14-2014, 05:43 AM
Has the Word version been changed (into 2007 , 2010 or 2013) ?

No.

macropod
04-14-2014, 06:45 PM
There is a fundamental difference between 'wdFormatXML' and 'wdFormatXMLDocument', in that the former creates an xml file whereas the latter creates a docx file. These file formats, not just the extensions, are quite different. Word 2003 cannot do a SaveAs with the 'wdFormatXMLDocument' property; it's not supported (AFAIK, not even with the docx file converter installed). So, are you sure you're looking for a .xml file as the output and not a .docx file?

slyguy
04-17-2014, 11:52 AM
There is a fundamental difference between 'wdFormatXML' and 'wdFormatXMLDocument', in that the former creates an xml file whereas the latter creates a docx file. These file formats, not just the extensions, are quite different. Word 2003 cannot do a SaveAs with the 'wdFormatXMLDocument' property; it's not supported (AFAIK, not even with the docx file converter installed). So, are you sure you're looking for a .xml file as the output and not a .docx file?

OK, I suppose that explains it. File is a docx, (though sometimes, we are provided a doc file). Most of our users are using Office 2007, though some 2010. What is wdFormatXMLDocument for then? I DO need to output XML that is the desired output. We do some transformations of the data to normalize it. Still back to my original problem, I was sent a file that does not save as XML. It just sits there (not frozen), just does nothing in the Save As dialog box. I was hoping someone has experienced this in the past and had found a solution or a cause and possibly a work around.

macropod
04-17-2014, 02:59 PM
What is wdFormatXMLDocument for then?
I described what that's for in the my previous reply - and you quoted it in your response!

Still back to my original problem, I was sent a file that does not save as XML. It just sits there (not frozen), just does nothing in the Save As dialog box.
It may be that the file is corrupt and/or that there's a problem with your office installation. Have you tried repairing the Office installation (via Programs & Features > Microsoft Office > Change in the Windows Control Panel)?

Corrupt documents can often be 'repaired' by inserting a new, empty, paragraph at the very end, copying everything except that new paragraph to a new document based on the same template, closing the old document and saving the new one over it.

slyguy
04-18-2014, 09:45 AM
I described what that's for in the my previous reply - and you quoted it in your response!

It may be that the file is corrupt and/or that there's a problem with your office installation. Have you tried repairing the Office installation (via Programs & Features > Microsoft Office > Change in the Windows Control Panel)?

Corrupt documents can often be 'repaired' by inserting a new, empty, paragraph at the very end, copying everything except that new paragraph to a new document based on the same template, closing the old document and saving the new one over it.

Well that's all it is a corrupt file. :doh:

You're awesome. :bow: I don't know if this answer will be good enough for the user, but I've spent too much time on a non-issue.