I have a c# project which makes mail merge between dotx file and xls files with Office.Interop version 12 and office 2013. It works in production but not in development, the same code runs with Interop version 14 and Office 2016 but I can't change server version. The error shows "HRESULT: 0x800706BE" and no more info. I've tried some folder access (everyone full access), install .net framework 1.1, change in component services, all of them without success. Does anyone have an idea of resolution?
Fails here:
Doc.MailMerge.OpenDataSource(Name: fileName, SQLStatement: sqlStmt);
It is not clear what are actual parameters passed to the OpenDataSource
method...
Anyway, try to use VBA macros for checking how the code works without relying on .net framework and other things. This example creates a new main document and attaches the Excel worksheet named Names.xls
. The Connection argument retrieves data from the range named "Sales."
Dim docNew As Document
Set docNew = Documents.Add
With docNew.MailMerge
.MainDocumentType = wdCatalog
.OpenDataSource Name:="C:\Documents\Names.xls", _
ReadOnly:=True, _
Connection:="Sales"
End With
User contributions licensed under CC BY-SA 3.0