Trouble saving XML format with Macro in Word 2003

vba , xml Denmark
  • 12 years ago

    With Word 2003, I defined a macro (with Record New Macro) to try to save a Word document as an XML file.  I don't need schema validation; I just want to save the file as XML.

    I get the Visual Basic error message: "Run-time error '6119': This document cannot be saved as XML because its structure violates the rules set by one or more attached schemas."

    There should be no attached schemas, and I don't want the file validated anyway.

    Saving the file manually with "Save as..." and choosing the *.xml file type, and checking the "Save data only" box works fine.  The recorded macro, which I thought would go through these same steps, does not work.

    Suggestions appreciated.  The macro is below

    Mike

     

    Sub SaveXML()
    '
    ' SaveXML Macro
    '
        With ActiveDocument
            .XMLSaveDataOnly = True
            .XMLUseXSLTWhenSaving = False
            .XMLSaveThroughXSLT = ""
            .XMLHideNamespaces = False
            .XMLShowAdvancedErrors = True
            .XMLSchemaReferences.HideValidationErrors = True
            .XMLSchemaReferences.AutomaticValidation = False
            .XMLSchemaReferences.IgnoreMixedContent = False
            .XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = True
            .XMLSchemaReferences.ShowPlaceholderText = False
        End With
        ActiveDocument.SaveAs FileName:="Process.xml", FileFormat:=wdFormatXML, _
            LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
            :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
            SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
            False
    End Sub

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski