Can't save .doc as .xml
What I'd like to achieve is to force MS Word not to split specific strings when saving .doc or .rtf file as .xml. For example, now from something like:
Something: ***TABLE_NAME.COLUMN_NAME***
or
Something: AAATABLE_NAME.COLUMN_NAMEBBB
or anything similar I get:
<w:p wsp:rsidR="00537583" wsp:rsidRDefault="00AF6BDF" wsp:rsidP="00537583">
<w:pPr>
<w:pStyle w:val="Default"/>
<w:jc w:val="both"/>
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
<w:t>Something: AAA</w:t>
</w:r>
<w:r wsp:rsidR="00537583">
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
<w:t>TABLE_NAME.</w:t>
</w:r>
<w:r wsp:rsidR="00537583" wsp:rsidRPr="00537583">
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
<w:t> COLUMN_NAME</w:t>
</w:r>
<w:r wsp:rsid开发者_开发知识库R="00537583">
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
<w:t>BBB</w:t>
</w:r>
</w:p>
and what I'd like to get is e.g.:
<w:p wsp:rsidR="00537583" wsp:rsidRDefault="00AF6BDF" wsp:rsidP="00537583">
<w:pPr>
<w:pStyle w:val="Default"/>
<w:jc w:val="both"/>
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:sz w:val="23"/>
<w:sz-cs w:val="23"/>
</w:rPr>
<w:t>Something: AAATABLE_NAME.COLUMN_NAMEBBB</w:t>
</w:r>
</w:p>
I'll be grateful for any ideas that will help to bypass this.
Two options spring to mind, if you can't get it to export as you want directly:
Create a plugin using VSTO (Link here)
Create an XSLT Template to reformat the XML appropriately
Word has an option to control whethr RSID entries are saved with a document. This is a a hidden application option only accessible via the Word object model.
To prevent that those ids are generated you can e.g. open the macro editor (Alt+F11) and execute the following code in the immediate window:
Application.Options.StoreRSIDOnSave = False
Without RSIDs all text having the same formatting will be contained in a single run (I think this is what you want to have).
The RSIDs are used by Word to automatically merge documents; they don't contain essential information needed for preserving a documents layout so saving is optional (unless you need to be able to merge documents).
精彩评论