Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
John G John G is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
John G John G is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MailMerge OpenDataSource SSPI direct SQL Server connection Thomas Mailmerge 3 July 10th 06 02:30 PM
excel hangs in mailmerge harrow Microsoft Word Help 2 October 21st 05 04:48 AM
MailMerge:OpenDataSource stackhouse Mailmerge 0 September 20th 05 04:17 PM
Statement parameter in Mailmerge.OpenDataSource Christof Nordiek Mailmerge 6 April 26th 05 09:31 AM
MailMerge.OpenDataSource not able to access a dynamic range name ? Bruce Cooley Mailmerge 2 April 17th 05 10:28 AM


All times are GMT +1. The time now is 08:28 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"