Consulting

Results 1 to 9 of 9

Thread: SaveAs XML not working

  1. #1
    VBAX Regular
    Joined
    Apr 2014
    Posts
    8
    Location

    SaveAs XML not working

    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!

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    Has the Word version been changed (into 2007 , 2010 or 2013) ?

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    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

  4. #4
    VBAX Regular
    Joined
    Apr 2014
    Posts
    8
    Location
    Quote Originally Posted by Paul_Hossler View Post
    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?

  5. #5
    VBAX Regular
    Joined
    Apr 2014
    Posts
    8
    Location
    Quote Originally Posted by snb View Post
    Has the Word version been changed (into 2007 , 2010 or 2013) ?
    No.

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #7
    VBAX Regular
    Joined
    Apr 2014
    Posts
    8
    Location
    Quote Originally Posted by macropod View Post
    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.

  8. #8
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by slyguy View Post
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  9. #9
    VBAX Regular
    Joined
    Apr 2014
    Posts
    8
    Location
    Quote Originally Posted by macropod View Post
    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.

    You're awesome. 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •