Here is some of my code that works with stored procedures:
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:=strConnect, _
SQLStatement:=strSQL
.Destination = wdSendToNewDocument
.Execute Pause:=False
End With
(Here strConnect is the path & name of an ODC or UDL file containing
the connection string. ) To answer your question, strSQL would be
something like this:
strSQL = "exec procMyStoredProc"
The exec part is necessary to make it work. You can append parameters
if needed.
Be aware that interoperability between Word and SQL Server just
sucks!! I wonder if anyone in the Word division has ever tried to use
it. One serious limitation is that your stored procedures must start
with the SELECT statement. You can't declare any variables, or do any
pre-processing; even SET NOCOUNT ON will cause it to fail.
cerullian
>Is there any way of persuading an OLEDB connection to accept a stored
>proceedure for mail merge?
[quoted text clipped - 3 lines]
>
>Michael