>Brian McNett wrote... > >Very nice if you have Clarisworks, which alas, I don't. Also, I'm rather >This sends the file to ANY printer? > >--B That MacPerl program opens the newly created file in ClarisWorks and brings up the print dialog. I haven't figured out how to bypass the dialog box (so I can send the file directly to the printer). Actually I have, but it uses KeyQuencer (macro utility) instead of AppleScript and I doubt many people have KeyQuencer installed. Perhaps a macro could be created in the wordprocessing program that could be executed by MacPerl using Applescript. The following version should work with Microsoft Word. It can be tested using the same template file (template_sample.rtf) I previously uploaded at http://macperl.com/depts/Code/_seay/Printer.hqx. You can omit the lines that change the creator code for the newly produced file. I added that so I can later double click the file's icon to open it in a specific wordprocessor. --------------- #!perl # rtf_printer.pl # v1.0 # by David D. Seay -- g-s@navix.net # # Sample program to demonstrate printing formatted output # using a previously saved 'rtf' template file. &get_rtf_file; &substitute_data; &save_changed_rtf_file; &open_new_file; exit(0); sub get_rtf_file { =3D09$programFolderPath =3D3D `pwd`; =3D09chomp($programFolderPath); =3D09$rtfFilePath =3D3D $programFolderPath . ":template_sample.rtf"; =3D09$fileSize =3D3D -s $rtfFilePath; =3D09open(FILEDATA, "$rtfFilePath" || die "Can't get $rtfFilePath... $^E" )= ; =3D09read(FILEDATA, $rtfTemplate, $fileSize); =3D09close(FILEDATA); } sub substitute_data { =3D09$to =3D3D "Ms. Example"; =3D09$rtfTemplate =3D3D~ s/toWhom/$to/; =3D09$newLine1 =3D3D "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise."; =3D09$rtfTemplate =3D3D~ s/line1/$newLine1/; =3D09$newLine2 =3D3D "--Larry Wall"; =3D09$rtfTemplate =3D3D~ s/line2/$newLine2/; =3D09$rtfTemplate =3D3D~ s/columns1/One\tTwo\tThree/; =3D09$from =3D3D "Mr. Example"; =3D09$rtfTemplate =3D3D~ s/fromWhom/$from/; } sub save_changed_rtf_file { =3D09$to =3D3D~ s/ /_/g; =3D09$newFile =3D3D "$to.rtf"; =3D09$filePathNew =3D3D $programFolderPath . ":" . $newFile; =3D09open(SAVEOUT, ">$filePathNew") || die "Could not save $filePathNew... $^E"; =3D09print SAVEOUT "$rtfTemplate"; =3D09close(SAVEOUT); =3D09# $newCreator =3D3D "BOBO"; # CLARISWORKS =3D09$newCreator =3D3D "MSWD"; # MICROSOFT WORKS =3D09&MacPerl::SetFileInfo($newCreator, "TEXT", "$filePathNew"); } sub open_new_file { # =3D09$script =3D3D <<END_SCRIPT; # =3D09tell application "ClarisWorks" # =3D09 activate # =3D09=3D09open file "$filePathNew" # =3D09 do menu menu item "Print=3D8A" of menu "File" # =3D09end tell =3D09$script =3D3D <<END_SCRIPT; =3D09tell application "Microsoft Word" =3D09 activate =3D09=3D09open file "$filePathNew" =3D09=3D09print window "$newFile" =3D09end tell END_SCRIPT =3D09&MacPerl::DoAppleScript($script); } __END__ # =3D3D=3D3D=3D3D=3D3D=3D3D Want to unsubscribe from this list? # =3D3D=3D3D=3D3D=3D3D=3D3D Send mail with body "unsubscribe" to macperl-re= quest@macp=3D erl.org