View Single Post
  #1   Report Post  
Adam Froio
 
Posts: n/a
Default Using an .odc File to Mailmerge with SQL Server

Hi,

I'm using an .odc file to pull data from SQL Server 2000 into a Word 2003
mailmerge.

My problem is getting the syntax correct so that I can dynamically create
sql statements to use for the merge.

For example, this works:
Word.MailMerge.OpenDataSource Name:="c:\mailmerge\CustomerData.odc",
SQLStatement:="SELECT * FROM [vwCustomerData]"

This, however, does not:
Word.MailMerge.OpenDataSource Name:="c:\mailmerge\vwCustomerData.odc",
SQLStatement:="SELECT * FROM [vwCustomerData] WHERE State = 'CT'"

I can't seem to find more than a couple examples on how to use an .odc in
this way and I can find none that use a sql statement any more complicated
than the first example above.

Any help or advice would be very much appreciated.

Thanks!
Adam