E
Egghead
Hi All,
I need to create labels off of my web site from a text file with
customer address information (or SQL database using a query) using
mail merge in word, programatically.
I'm using the following sample code (relevant parts) to do the same.
but it gets hung on the open datasource part.
I was able to see it the first time, not the data in the text file,
but it opened the mail merged word document with 2 lines, record1
contains too few records, record2 contains too few records..
now, the code doesn't do anything , but just hung on open datasource
part.
Any suggestions?
Any help would be greatly appreciated
Thanks,
E.
Sample Code.
Word.Application wrdApp;
Word._Document oDataDoc;
wrdApp = new Word.Application();
wrdApp.Visible = true;
object oTrue = true;
oDataDoc = wrdApp.Documents.Add(ref Template, ref oMissing, ref
oMissing, ref oFalse);
object oFormat = "wdOpenFormatAuto";
object oEmpty = "";
object oSubtype = Word.WdMergeSubType.wdMergeSubTypeOther ;
oDataDoc.MailMerge.MainDocumentType =
WdMailMergeMainDocType.wdMailingLabels;
oDataDoc.MailMerge.OpenDataSource("C:\\Els_Import\\MailMergeXCL.txt", //sName,
ref oFormat, //wdOpenFormatText
ref oFalse, //ConfirmConversions
ref oFalse, //ReadOnly
ref oFalse, //LinkToSource
ref oFalse, //AddToRecentFiles
ref oEmpty, //PasswordDocument
ref oEmpty, //PasswordTemplate
ref oFalse, //Revert
ref oEmpty, //WritePasswordDocument
ref oEmpty, //WritePasswordTemplate
ref oEmpty, //Connection
ref oEmpty, //SQLStatement
ref oEmpty, //SQLStatement1
ref oFalse,
ref oSubtype
);
oDataDoc.MailMerge.Destination =
Word.WdMailMergeDestination.wdSendToNewDocument;
oDataDoc.MailMerge.Execute(ref oFalse);
I need to create labels off of my web site from a text file with
customer address information (or SQL database using a query) using
mail merge in word, programatically.
I'm using the following sample code (relevant parts) to do the same.
but it gets hung on the open datasource part.
I was able to see it the first time, not the data in the text file,
but it opened the mail merged word document with 2 lines, record1
contains too few records, record2 contains too few records..
now, the code doesn't do anything , but just hung on open datasource
part.
Any suggestions?
Any help would be greatly appreciated
Thanks,
E.
Sample Code.
Word.Application wrdApp;
Word._Document oDataDoc;
wrdApp = new Word.Application();
wrdApp.Visible = true;
object oTrue = true;
oDataDoc = wrdApp.Documents.Add(ref Template, ref oMissing, ref
oMissing, ref oFalse);
object oFormat = "wdOpenFormatAuto";
object oEmpty = "";
object oSubtype = Word.WdMergeSubType.wdMergeSubTypeOther ;
oDataDoc.MailMerge.MainDocumentType =
WdMailMergeMainDocType.wdMailingLabels;
oDataDoc.MailMerge.OpenDataSource("C:\\Els_Import\\MailMergeXCL.txt", //sName,
ref oFormat, //wdOpenFormatText
ref oFalse, //ConfirmConversions
ref oFalse, //ReadOnly
ref oFalse, //LinkToSource
ref oFalse, //AddToRecentFiles
ref oEmpty, //PasswordDocument
ref oEmpty, //PasswordTemplate
ref oFalse, //Revert
ref oEmpty, //WritePasswordDocument
ref oEmpty, //WritePasswordTemplate
ref oEmpty, //Connection
ref oEmpty, //SQLStatement
ref oEmpty, //SQLStatement1
ref oFalse,
ref oSubtype
);
oDataDoc.MailMerge.Destination =
Word.WdMailMergeDestination.wdSendToNewDocument;
oDataDoc.MailMerge.Execute(ref oFalse);