简体   繁体   English

Delphi Word自动化 - 打印合并文档

[英]Delphi Word automation - print merged document

My D5 application can currently mail merge multiple members data to a Word document using: 我的D5应用程序当前可以使用以下方式将多个成员数据合并到Word文档:

wrdapp := CreateOleObjct(word.application);
wrdDoc := wrdApp.Document.Open(TemplateLocation);
wrdMailMerge := wrdDoc.MailMerge;
populateMailMergeDateFile;
wrdMailMerge.execute;

and then 然后

wrdDoc.Saved := False;
wrdDoc.Close(False);
wrdApp.Visible := True;

I would like to offer the option of passing the merged document straight to the printer. 我想提供将合并文档直接传递给打印机的选项。 However I cannot find the code which allows this to happen 但是我找不到允许这种情况发生的代码

wrdDoc.PrintOut;
wrdDoc.Saved := False;
wrdDoc.Close(False);

Prints out the template document with no merged data. 打印出没有合并数据的模板文档。

wrdDoc.Saved := False;
wrdDoc.Close(False);
wrdDoc.PrintOut;

Displays a variant object error. 显示变体对象错误。

wrdMailMerge.PrintOut;

Displays an automation errors. 显示自动化错误。

I've tried using True instead of False as well. 我也试过使用True而不是False。 Can anybody advise me as to how to print the merged document correctly? 任何人都可以告诉我如何正确打印合并文档?

many thanks 非常感谢

在我的mailmerge代码中,我在执行合并之前将MailMerge.Destination设置为wdSendToNewDocument,然后我调用WordApplication.ActiveDocument.Printout。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM