http://qs321.pair.com?node_id=671078

xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi gurus,

I'd like to print 60 doc(word format) files. I've tried to choose all files and print, but system open one word window for each file, and end up with crushing!
Is there any way to solve this problem in perl?
Thanks in millions

I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: How print doc files in a row
by moklevat (Priest) on Feb 29, 2008 at 03:02 UTC
    It may depend on how you are invoking Word. It looks like the following command line switches should work:

    "c:\program files\microsoft office\office11\winword.exe" "c:\perl\test.doc" /q /n /mFilePrintDefault /mFileExit

    Without seeing your code and a better description of what happens, this is the best I can do.

      Thanks!!;
      below is my snippet:
      my $dir; opendir ($dir, ".") or die "error!\n"; for my $file_name (readdir $dir) { next if $file_name =~ m/^\./; system("c:\\program\ files\\microsoft\ office\\office10\\winword.e +xe", "$file_name", "/q", "/n", "/mFilePrintDefault", "/mFileExit"); sleep 10; }

      I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
        Not sure if that was a typo, but you have some back-slashes missing from your system call, should be:
        system("c:\\program\\files\\microsoft\\office\\office10\\winword.exe", + "$file_name", "/q", "/n", "/mFilePrintDefault", "/mFileExit");
        One option to stop the windows showing is to run the program with the C API CreateProcess and set the SW_HIDE attribute to the main Window, unfortunately it looks like Win32::Process does not support that.:(
Re: How print doc files in a row
by wfsp (Abbot) on Feb 29, 2008 at 08:20 UTC
Re: How print doc files in a row
by CountZero (Bishop) on Feb 29, 2008 at 06:36 UTC
    Maybe is this freeware program what you are looking for?

    Otherwise, I would suggest you only feed Word one file at a time. Yes this will mean that you have to wait until each file has been send to the printer and yes this means that you have to re-start Word time-and-time-again (which is inefficient and slow).

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: How print doc files in a row
by spatterson (Pilgrim) on Feb 29, 2008 at 16:05 UTC
    Can I advertise an old module of mine? :P Printer

    just another cpan module author