I’m using automation to perform a mail merge. I have a couple of questions… To open the datasource i am using the following code, CLEAR(MSWordDocument); CLEAR(MSWordApplication); CREATE(MSWordApplication); MSWordApplication.Visible(TRUE); MSWordDocument := MSWordApplication.Documents.OpenOld(TemplatePathAndName); MSWordApplication.Activate; //MsExcelWorkbook := MsExcelApplication.ActiveWorkbook; DummyTrue := 1; DummyFalse := 0; dummyText := ‘Entire Spreadsheet’; dummyInt := 0; MSWordDocument.MailMerge.OpenDataSource2000(DataSourcePahtAndName, dummyInt, DummyFalse, DummyFalse, DummyTrue, DummyFalse, dummyblank, dummyblank, DummyFalse, dummyblank, dummyblank, dummyText, dummyblank, dummyblank); MSWordDocument.MailMerge.Destination(0); //wdSendToNewDocument MSWordDocument.MailMerge.DataSource.FirstRecord(FromLineNo); //wdDefaultFirstRecord MSWordDocument.MailMerge.DataSource.LastRecord(ToLineNo);//wdDefaultLastRecord MSWordDocument.MailMerge.Execute; The problem i have is that when i open the datasource it is asking which sheet in the excel file contains the headers. Is there a way to automate this so that it will automatically point to sheet one in the excel workbook? Also it seems to open the template i’m working from and the document which it is producing from the template. I don’t want to show the template to the user. How can i prevent this? Any help will be appreciated. Thanks Adrian
We were running it in 2000 using 97 objects. I have just tested on a 97 build and it works as i want it to. Thanks