Word Open XML Mail Merge - ms-word

I'm attempting to manually create a mail merge using Word's XML (from Word 2007). I have the following XML which isn't working:
<w:mailMerge>
<w:mainDocumentType w:val="catalog" />
<w:linkToQuery />
<w:dataType w:val="native" />
<w:connectString w:val="Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=TheServer;Data Source=." />
<w:query w:val="SELECT * FROM `Table` WHERE `id_field` = 7" />
<w:dataSource r:id="rId1" />
<w:activeRecord w:val="0" />
</w:mailMerge>
I can't really figure out from the documentation what I'm supposed to do. This is just a mail merge from a database table. It says there's an error on the line <w:mainDocumentType w:val="catalog" />. I've looked up possible values of w:val without any luck. I can't find any decent documentation on it.
Anyone have any ideas?

DII has all of the documentation and you can also look up on this site, like the mainDocumentType is listed as a CT_MailMergeDocType. Upon searching for that, I get which then tells me to look up ST_MailMergeDocType, where it lists the types.
Also, OpenXML Developer has some basic intro articles to MailMerge with WordprocessingML:
Mail merge in WordProcessingML using
System.IO.Packaging API
Mail Merge in WordProcessingML

Can this be of some help?
Mail Merging With Word and Linq-to-Xml in VB

in your sql command you aren't using regular single quotes (') but the kind i see when people have international keyboards ( "`" vs "'" ). i don't know how the SQLOLEDB provider works but i am used to seeing brackets around table and cloumn names rather than quotes.
using microsoft word, set up mail merging in a test document just how you want it. then view the xml that word generated using the Open XML SDK Tool which you can get here:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=5124
compare the xml that word generates to your code to see where you may have gone wrong.
note that a w:mailMerge may depend on an external resource, in which case you include a data source reference.

Related

openXml word..mergefield is corrupted

I'm trying to do a mail merge, and having issues at the PRE-merge stage..ie, as soon as write the .docx.
The xml tag in question is: «customer_name»
In the XML, the tags, and single quotes, behave fine..
..UNTIL a single quote sits DIRECTLY next to the mail merge delimiter..
ie «customer_name»’
Then, when i look at the xml, the tag is split:
<w:t>«</w:t>
<w:t>customer_name»</w:t>
<w:t>’s</w:t>
Does anyone have any pointers?
Many thanks,
Chris

Generate .hhk file From Word Document

I am trying to convert MS Word file to chm file. I have a well organized word document. But,I could not figure out how to word saved as a html file to chm file. I know I can add html file to created project but there are some issue such that I could not solve how to convert ms word table of content file to index file in html help workshop program. I would be very happy If someone provide some example about conversion of word documents.(I am trying to achieve this thorough HTML Help Workshop program)
Best regards,
Converting a Word document to CHM format is difficult without special (often expensive) tools and has a learning curve.
You should think about whether the PDF format is not sufficient. But the CHM format - integrated in the Windows operating system - has of course some popular functions.
I recommend to read through Search and Index not working after converting from Word 2016 to CHM.
As I mentioned in my answer I never used chmProcessor before (because using other tools) but surprisingly seems to be a good one for converting Word documents in a simple way.
Please try chmProcessor for your needs. You may want to ask a new question here on SO later.
Edit:
Maybe you have additional interest in the following CodeProject article:
How to Easily Write a User's Guide for Your Application using Different File Extensions

WordML Schema generation

I need the xml template for Word 2007. In Word 2003 it starts like the following and continues. What I need is the generic template of Word 2007 in xml format which can be used as the base for WordML to xml transformations and viceversa. Someone experienced in WordML would definitely know what I am asking for! If you have used docbook roundtripping, what I need is the template document which can be used for the "wordml.template" parameter. The template for Word 2003 is already there. I need the template for Word 2007. If someone knows please let me know how to have that. Thanks!
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument>xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"..........."
See my answer to your earlier question (which got closed): XML schema for Offfice 2007
There is a difference between a sample XML file which validates against a schema, and the schema itself.
I told you how to create a sample XML file, which, best I can tell, is what you are still asking for here.
Open the Word 2003 template in Word, then "save as" XML (Word 2007 XML). That should do it.
There is more than one schema. You may be able to get them here:
http://www.microsoft.com/en-us/download/details.aspx?id=4463

how do I correctly paste multi-line xml snippet to github wiki when using markdown

I am trying to create a github wiki for my project. But I am unable to format a snippet from a Spring beans xml file, into this wiki. What is the proper way to do it? I tried using pre tag, code tag, the multiline code tag etc. But either it is not getting displayed at all or It displays everything in the same line.
not 100% sure if this is the same thing or not, but I just setup some xml snippets in my readme.md and used the
<myxml>
<someElement />
</myxml>
notation.
Replace all the less-than < and greater-than > symbols with < and > respectively, then wrap in <pre> and <code> as before.
An old question, however, the solution has changed in the interim. Simply use the ```xml tag on modern mark-down implementations.
```xml
<your XML here>
.```
Example:
<one>
<two>
</two>
</one>
It's that simple and it works far better than embedding the XML as described above.

Writing MS Word 2007 XML

How would I write Word 2007 XML (WordProcessingML) on my own? I have a requirement to do so, where I need to write a Word 2007 XML format for a Word template. The important thing is I should convert a Word template doc to XML (by zipping it, etc), where I need to write Word 2007 XML with those respective tags. How can I do this?
docx4j
I'm not sure what you mean by "on your own," but there is an existing API for this:
Apache POI - the Java API for Microsoft Documents
If it doesn't do what you need it to, just extend it.
Go to OpenXMLDeveloper - you can get most of the information there on WordprocessingML and links out to other places.