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; |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge hangs at OpenDataSource
First, I would try
Object oSubType = Word.WdMergeSubType.wdMergeSubTypeWord2000; Next, I would probably try to use a much simpler piece of SQL (SELECT * FROm [mytable] until everything else is sorted out. Next, I would check that the DSN contained everything needed for connection (typically, username and password are not saved in the DSN even though it sometimes appears from the DSN setup that they are. With SQL Server, you should however be OK if you are using Windows Integrated Security. Next, I would probably add an alias name for the /table/ and use it to qualify each field name. -- Peter Jamieson http://tips.pjmsn.me.uk "John G" wrote in message oups.com... 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; |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge hangs at OpenDataSource
Thanks Peter. I tried countless examples. I took the same example
and did it on another machine and it worked fine. Not sure what it could be. Thanks for your help On Aug 27, 5:56 am, "Peter Jamieson" wrote: First, I would try Object oSubType = Word.WdMergeSubType.wdMergeSubTypeWord2000; Next, I would probably try to use a much simpler piece of SQL (SELECT * FROm [mytable] until everything else is sorted out. Next, I would check that the DSN contained everything needed for connection (typically, username and password are not saved in the DSN even though it sometimes appears from the DSN setup that they are. With SQL Server, you should however be OK if you are using Windows Integrated Security. Next, I would probably add an alias name for the /table/ and use it to qualify each field name. -- Peter Jamiesonhttp://tips.pjmsn.me.uk "John G" wrote in message oups.com... 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;- Hide quoted text - - Show quoted text - |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge hangs at OpenDataSource
Does the same DSN work correctly with other software (e.g. Excel, MS Query)
on the original machine? -- Peter Jamieson http://tips.pjmsn.me.uk "John G" wrote in message ups.com... Thanks Peter. I tried countless examples. I took the same example and did it on another machine and it worked fine. Not sure what it could be. Thanks for your help On Aug 27, 5:56 am, "Peter Jamieson" wrote: First, I would try Object oSubType = Word.WdMergeSubType.wdMergeSubTypeWord2000; Next, I would probably try to use a much simpler piece of SQL (SELECT * FROm [mytable] until everything else is sorted out. Next, I would check that the DSN contained everything needed for connection (typically, username and password are not saved in the DSN even though it sometimes appears from the DSN setup that they are. With SQL Server, you should however be OK if you are using Windows Integrated Security. Next, I would probably add an alias name for the /table/ and use it to qualify each field name. -- Peter Jamiesonhttp://tips.pjmsn.me.uk "John G" wrote in message oups.com... 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;- Hide quoted text - - Show quoted text - |
Reply |
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 |