C
ChrisRS
I am using C# with Visual Studio 2005 with Office 2003 mail merging data from
an SQL database.
The merge works successfully using various templates and various SQL queries
and creates the final merged document. However only fields which are datetime
fields are outputted and text fields are left blank in the Word doc. The
fields in the query do contain data and no errors are produced.
Any ideas on what can be causing this?
A small section of the merge code is shown below (if that helps)
Cheers
Chris
-----------------------
wrdApp = new Microsoft.Office.Interop.Word.ApplicationClass();
wrdApp.Visible = true;
oDataDoc = wrdApp.Documents.Add(ref oName, ref oFalse, ref oMissing, ref
oMissing);
oDataDoc.Activate();
wrdMailMerge = oDataDoc.MailMerge;
wrdMailMerge.HighlightMergeFields = true;
oQuery = stat.Text; // stat field contains SQL query
wrdMailMerge.OpenDataSource("", ref oFileFormat, ref oMissing, ref oMissing,
ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oFalse, ref
oMissing, ref oMissing, ref oConnection, ref oQuery, ref oMissing, ref
oMissing, ref oSubType);
// i think the above line of code is causing the problem
wrdMailMerge.SuppressBlankLines = true;
wrdMailMerge.Destination =
Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument;
wrdMailMerge.Execute(ref oFalse);
oDataDoc.Close(ref oFalse, ref oMissing, ref oMissing);
------------------
an SQL database.
The merge works successfully using various templates and various SQL queries
and creates the final merged document. However only fields which are datetime
fields are outputted and text fields are left blank in the Word doc. The
fields in the query do contain data and no errors are produced.
Any ideas on what can be causing this?
A small section of the merge code is shown below (if that helps)
Cheers
Chris
-----------------------
wrdApp = new Microsoft.Office.Interop.Word.ApplicationClass();
wrdApp.Visible = true;
oDataDoc = wrdApp.Documents.Add(ref oName, ref oFalse, ref oMissing, ref
oMissing);
oDataDoc.Activate();
wrdMailMerge = oDataDoc.MailMerge;
wrdMailMerge.HighlightMergeFields = true;
oQuery = stat.Text; // stat field contains SQL query
wrdMailMerge.OpenDataSource("", ref oFileFormat, ref oMissing, ref oMissing,
ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oFalse, ref
oMissing, ref oMissing, ref oConnection, ref oQuery, ref oMissing, ref
oMissing, ref oSubType);
// i think the above line of code is causing the problem
wrdMailMerge.SuppressBlankLines = true;
wrdMailMerge.Destination =
Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument;
wrdMailMerge.Execute(ref oFalse);
oDataDoc.Close(ref oFalse, ref oMissing, ref oMissing);
------------------