mail merge problems

K

Katie

I need to automate a mail merge from a form in my access 2002 database. I've
tried importing the code from a recommended site

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html


but keep getting an error - 424 -object required, something to do with the
line ...

Set WordDoc = wordApp.Documents.Add

I have no coding experience but i need this to work - any help would be
greatly appreciated!!

Thanks
 
E

Egghead

Hi All,

sorry to post a question as a follow up to this query, i didn't know
how to put a new one.

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top