如何使用VB在活动word文档中多次插入SQL Server结果

时间:2022-09-13 09:53:21

Ok, I'm stuck trying to figure out how to take a mail merge, use that info to make MS SQL calls and get strings back in a word document. I'm guessing VB but I have no VB experience.

好吧,我一直试图找出如何进行邮件合并,使用该信息进行MS SQL调用并在word文档中获取字符串。我猜VB但我没有VB经验。

1 个解决方案

#1


If you want do a mail merge using data from SQL Server then (in Word 2003 anyway) there's an option on step 3 of the mail merge wizard:

如果你想使用SQL Server中的数据进行邮件合并,那么(无论如何在Word 2003中)在邮件合并向导的第3步有一个选项:

Use an existing list > Browse > New SQL Server connection

使用现有列表>浏览>新建SQL Server连接

If you want to take the results of a mail merge from some other data source and then query SQL Server with those results then you're going to need VBA. As well as working out how to manipulate data in the Word object model, you're going to need something like ActiveX Data Objects (ADO) for the database queries

如果您想从其他数据源获取邮件合并的结果,然后使用这些结果查询SQL Server,那么您将需要VBA。除了研究如何操作Word对象模型中的数据之外,您还需要一些类似ActiveX数据对象(ADO)的数据库查询

#1


If you want do a mail merge using data from SQL Server then (in Word 2003 anyway) there's an option on step 3 of the mail merge wizard:

如果你想使用SQL Server中的数据进行邮件合并,那么(无论如何在Word 2003中)在邮件合并向导的第3步有一个选项:

Use an existing list > Browse > New SQL Server connection

使用现有列表>浏览>新建SQL Server连接

If you want to take the results of a mail merge from some other data source and then query SQL Server with those results then you're going to need VBA. As well as working out how to manipulate data in the Word object model, you're going to need something like ActiveX Data Objects (ADO) for the database queries

如果您想从其他数据源获取邮件合并的结果,然后使用这些结果查询SQL Server,那么您将需要VBA。除了研究如何操作Word对象模型中的数据之外,您还需要一些类似ActiveX数据对象(ADO)的数据库查询