Recorded Macro to Print Merge to Printer Requires SendKeysLast reviewed: July 30, 1997Article ID: Q74913 |
The information in this article applies to:
SUMMARYIn order to use a macro to send a merged a document directly to the printer, the macro must include the SendKeys macro command. Without the SendKeys macro command, the Print dialog box remains on the screen.
MORE INFORMATION
Visual Basic for ApplicationsAdd a SendKeys statement to send the {enter} key to the Print dialog box. The SendKeys statement should precede the Mail Merge statements, as in the following Visual Basic for Applications example;
Sub MergeAndPrint() SendKeys "{enter}" With ActiveDocument.MailMerge .Destination = wdSendToPrinter .Execute End With End SubIf you don't need to send the document directly to the printer, you can merge it to a new document and then print it. The following sample Visual Basic for Applications macro merges to a new document and prints the document:
Sub MergeToDocAndPrint() With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .Execute End With ActiveDocument.PrintOut End Sub WordBasicWord 6.x, 7.x: Add a SendKeys statement to send the {enter} key to the Print dialog box. The SendKeys statement should precede the MailMergeToPrinter statement as in the following example.
Sub MAIN SendKeys "{enter}" MailMergeToPrinter End SubIf you don't need to send the document directly to the printer, you can merge it to a new document and then print it. The following example macro merges to a new document, prints the document, and then closes the document:
Sub MAIN MailMergeToDoc FilePrint FileClose 2 End SubWord 2.0: If a macro is recorded to merge a document to the printer, the macro has the following commands (there may be different values for the parameters, depending on your choices in the dialog boxes):
Sub MAIN FilePrintMerge .MERGERECORDS = 0, .From = "", \ .To = "", .PRINT FilePrint .Type = 0, .NumCopies = "1", .Range = 0,\ .From = "", .To = "", .Reverse = 0, .Draft = 0,\ .UpdateFields = 0, .PaperFeed = 8, .Summary = 0, \ .Annotations = 0, .ShowHidden = 0, .ShowCodes = 0,\ .FileName = "" End SubNOTE: The backslashes (\) indicate the command is continued on the next line. Do not include the backslashes in your macro. For the macro to work correctly, the following command must be inserted before the FilePrintMerge command:
SendKeys "{enter}", -1Multiple Copies: If you want to print more than one copy of your merged document, use the following SendKeys command to modify the Copies box in the Print dialog box:
SendKeys "N{ENTER}", -1NOTE: "N" is the number of copies you want to print.
REFERENCES"Microsoft Word for Windows Technical Reference," pages 88-90 "Microsoft Word for Windows and OS/2 Technical Reference," pages 251-253 Kbcategory: kbusage kbmacro KBSubcategory: kbmerge
|
Additional query words: 1.x 2.0 word6 winword 2.0a 2.0a-CD 1.x
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |