J
John G
I have the follow app that always hangs when i get to the
OpenDataSource method. Any Ideas? Thanks in Advance
Word.Application wrdApp;
Word.Document oDataDoc;
Word.MailMerge wrdMailMerge;
Object oMissing = System.Type.Missing;
Object oFalse = false;
Object oTrue = true;
Object oName = "C:\\Documents and Settings\\John\\Desktop\
\EDP\\cardprocess\\idcardsmmeastern-x4.doc";
Object oFileName = @"c:\saved.rtf";
Object oFileFormat = Word.WdSaveFormat.wdFormatRTF;
// Starting the Word Application
wrdApp = new Word.ApplicationClass();
wrdApp.Visible = true;
wrdApp.WindowState =
Word.WdWindowState.wdWindowStateMaximize;
// Open the template
oDataDoc = wrdApp.Documents.Add(ref oName, ref oFalse, ref
oMissing, ref oMissing);
oDataDoc.Activate();
// Document 2 mailmerge format
wrdMailMerge = oDataDoc.MailMerge;
wrdMailMerge.HighlightMergeFields = false;
//wrdMailMerge.ViewMailMergeFieldCodes = 0; //this is for
showing the data instead of fieldnames
// The data part
Object oConnection = "DSN=Edentalnew"; //The DSN
connection name
Object oQuery = "SELECT top 10 mblname LastName, mbfname
FirstName FROM [lumemb]"; // The query to get data from the DSN
Object oSubType = Word.WdMergeSubType.wdMergeSubTypeWord;
//Open the data source and merge the fields
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);
wrdMailMerge.SuppressBlankLines = true;
// Save document
oDataDoc.SaveAs(ref oFileName, ref oFileFormat, ref
oMissing, ref oMissing, ref oTrue, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing, ref oMissing);
oDataDoc.Saved = true;
// Unload objects from the memory
wrdMailMerge = null;
oDataDoc = null;
wrdApp = null;
OpenDataSource method. Any Ideas? Thanks in Advance
Word.Application wrdApp;
Word.Document oDataDoc;
Word.MailMerge wrdMailMerge;
Object oMissing = System.Type.Missing;
Object oFalse = false;
Object oTrue = true;
Object oName = "C:\\Documents and Settings\\John\\Desktop\
\EDP\\cardprocess\\idcardsmmeastern-x4.doc";
Object oFileName = @"c:\saved.rtf";
Object oFileFormat = Word.WdSaveFormat.wdFormatRTF;
// Starting the Word Application
wrdApp = new Word.ApplicationClass();
wrdApp.Visible = true;
wrdApp.WindowState =
Word.WdWindowState.wdWindowStateMaximize;
// Open the template
oDataDoc = wrdApp.Documents.Add(ref oName, ref oFalse, ref
oMissing, ref oMissing);
oDataDoc.Activate();
// Document 2 mailmerge format
wrdMailMerge = oDataDoc.MailMerge;
wrdMailMerge.HighlightMergeFields = false;
//wrdMailMerge.ViewMailMergeFieldCodes = 0; //this is for
showing the data instead of fieldnames
// The data part
Object oConnection = "DSN=Edentalnew"; //The DSN
connection name
Object oQuery = "SELECT top 10 mblname LastName, mbfname
FirstName FROM [lumemb]"; // The query to get data from the DSN
Object oSubType = Word.WdMergeSubType.wdMergeSubTypeWord;
//Open the data source and merge the fields
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);
wrdMailMerge.SuppressBlankLines = true;
// Save document
oDataDoc.SaveAs(ref oFileName, ref oFileFormat, ref
oMissing, ref oMissing, ref oTrue, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing, ref oMissing, ref oMissing, ref oMissing);
oDataDoc.Saved = true;
// Unload objects from the memory
wrdMailMerge = null;
oDataDoc = null;
wrdApp = null;