Trouble saving XML format with Macro in Word 2003

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


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:= _
End Sub

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!