I want to create a MS Word merge document. I have already created a template document. When my application is started, it creates an ODBC, called "Hrms2008". I am new to this kind of stuff, that's why I don't know what causes the error.
word.Application wrdApp;
word.Document wrdDoc;
object oMissing = System.Reflection.Missing.Value;
object oName = "DSN=Hrms2008;DATABASE=Pitshrms4002;Integrated Security = True;";
object oSQL = "Select * from tiblMerge";
object oTemplate = briefNieuw.Brief;
wrdApp = new word.Application();
wrdApp.Visible = true;
wrdDoc = wrdApp.Documents.Add(ref oTemplate,ref oMissing,ref oMissing,ref oMissing);
wrdDoc.MailMerge.MainDocumentType = word.WdMailMergeMainDocType.wdFormLetters;
wrdDoc.MailMerge.OpenDataSource("", oName, oSQL);
The error I get: "Type mismatch. Exception from HRESULT: 0X80020005 (DISP_ETYPEMISMATCH)"
What am I doing wrong here?