Word 2013 Mailmerge - 从excel编辑mailmerge的select语句 [英] Word 2013 Mailmerge - Edit select statement for mailmerge from excel
问题描述
你好,
我目前正在尝试从excel电子表格创建一个mailmerge。
电子表格的所有名字都是一个人我只需要第一个名字。
我试图使用自定义SELECT语句编辑mailmerge的ActiveDocument.MailMerge.DataSource.QueryString属性:
ActiveDocument.MailMerge.DataSource.QueryString =" SELECT Name,Address,City,LEFT(Firstnames,INSTR(1,Firstnames,'') - 1)AS Firstnames FROM [Tab1 $]"
但似乎单词不喜欢查询,因为它返回错误4198'执行失败'执行此行。
我不知道我使用的SQL函数是否正确,甚至是否可以编辑Select语句中的字段...
有什么想法吗?
嗯。以下语法适用于我:
qs =" SELECT Lastname,LEFT(Firstname,INSTR(Firstname,''))AS Firstname FROM [Sheet1
"
ActiveDocument.MailMerge.DataSource.QueryString = qs
我没有指定"开始"和"开始"。 INSTR的参数。可能,查询引擎的字符串函数功能不支持吗?
(注意我的字段名称与您的字段名称略有不同,我的工作表名称也是如此)。
Hello,
I am currently trying to create a mailmerge from an excel spreadsheet.
The spreadsheet is given with all firstnames of a person while I only need the first firstname.
I've tried to edit the ActiveDocument.MailMerge.DataSource.QueryString property of the mailmerge with a custom SELECT statement :
ActiveDocument.MailMerge.DataSource.QueryString = "SELECT Name, Address, City, LEFT(Firstnames, INSTR(1, Firstnames, ' ') - 1) AS Firstnames FROM [Tab1$]"
However it seems like word doesn't like the query as it returns an error 4198 'Execution has failed' upon the execution of this very line.
I don't know if the SQL functions I am using are right nor if it is even possible to edit the fields in the Select statement...
Any idea?
Mmmm. The following syntax works for me:
qs = "SELECT Lastname, LEFT(Firstname, INSTR(Firstname, ' ')) AS Firstname FROM [Sheet1
" ActiveDocument.MailMerge.DataSource.QueryString = qsI didn't specify the "Start" parameter of INSTR. Possibly, the string function capability of the Query engine doesn't support that?
(Note my field names differ slightly from yours, as does my sheet name).
这篇关于Word 2013 Mailmerge - 从excel编辑mailmerge的select语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!