Word 打开 XML 邮件合并
我正在尝试使用 Word 的 XML(来自 Word 2007)手动创建邮件合并。我有以下无效的 XML:
<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>
我无法从文档中真正弄清楚我应该做什么。这只是来自数据库表的邮件合并。它表示
行有错误。我已经查找了 w:val
的可能值,但没有任何运气。我找不到任何像样的文档。
有人有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在你的sql命令中,你没有使用常规的单引号('),而是我在人们使用国际键盘时看到的那种单引号(“`”与“'”)。我不知道 SQLOLEDB 提供程序如何工作,但我习惯于看到表和列名称周围的括号而不是引号。
使用 Microsoft Word,按照您想要的方式在测试文档中设置邮件合并。然后查看使用 Open XML SDK 工具生成的 xml,您可以在此处获取该工具:
http://www.microsoft.com/download/en /details.aspx?displaylang=en&id=5124
将 word 生成的 xml 与您的代码进行比较,看看哪里可能出了问题。
请注意,aw:mailMerge 可能依赖于外部资源,在这种情况下,您需要包含数据源引用。
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.
这能有一些帮助吗?
在 VB 中与 Word 和 Linq-to-Xml 进行邮件合并
Can this be of some help?
Mail Merging With Word and Linq-to-Xml in VB
DII 拥有所有文档,您也可以查找此文档站点,例如
mainDocumentType
被列为CT_MailMergeDocType
。搜索后,我得到它然后告诉我查找ST_MailMergeDocType
,其中列出了类型。另外,OpenXML Developer 有一些使用 WordprocessingML 进行 MailMerge 的基本介绍文章:
System.IO.Packaging API
DII has all of the documentation and you can also look up on this site, like the
mainDocumentType
is listed as aCT_MailMergeDocType
. Upon searching for that, I get which then tells me to look upST_MailMergeDocType
, where it lists the types.Also, OpenXML Developer has some basic intro articles to MailMerge with WordprocessingML:
System.IO.Packaging API