tags:

views:

139

answers:

2

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:rsidR="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.

+2  A: 

Two options spring to mind, if you can't get it to export as you want directly:

  1. Create a plugin using VSTO (Link here)

  2. Create an XSLT Template to reformat the XML appropriately

Nick Haslam
A: 

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).

0xA3
Works great, thanks so much.I hope my coworkers will also like that solution ;)
brovar
My joy was a bit premature as it doesn't work with Word 2007 - any idea why?...
brovar
I've tried this with Word 2007. What kind of XML format did you choose from the available XML formats? This should work at least for Word 2003 XML format.
0xA3
And also note that only text runs with identical formatting will be combined.
0xA3
I doublechecked the formatting, everything is (and was) as it should be. And now I'm confused, because this time it worked with both XML formats. I've got an impression Word sometimes changes this option back to True or at least doesn't accept it at the first time - is this even possible?
brovar
Are you sure your document was actually saved? Afaik Word will only save your document if it contains modifications.
0xA3
Yep, everything was fine - I just made damn stupid mistake, preceding the command with a "?" and not noticing it while using ctrl+c/ctrl+v. No wonder Word refused to store the value. Thank you again for all your help.
brovar