Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge hangs at OpenDataSource
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; |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MailMerge OpenDataSource SSPI direct SQL Server connection | Mailmerge | |||
excel hangs in mailmerge | Microsoft Word Help | |||
MailMerge:OpenDataSource | Mailmerge | |||
Statement parameter in Mailmerge.OpenDataSource | Mailmerge | |||
MailMerge.OpenDataSource not able to access a dynamic range name ? | Mailmerge |