Hello,

I am looking for some help from anyone expereienced with Win32::OLE

I have been trying to automate the task of converting a .doc file to postscript by using Perl and Win32::OLE to drive MS-Word.
I have learned how to print a file and how to call up the PrintToFile dialog box by using Win32::OLE.
My problem is that when I set "PrToFileName" to automate the process of printing to a file, nothing happens.
Here is my test code

#!/usr/bin/perl use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; #Where the temp file sent from the client is my $file = 'c:\temp\final.doc'; #Open MS Word my $Word = Win32::OLE->new('Word.Application', 'Quit'); $Word->{'Visible'} = 1; # if you want to see what's going on #Open the file $Word->Documents->Open($file); $Word->ActiveDocument->PrintOut({ Background => 0, Append => 0, Range => wdPrintAllDocument, Item => wdPrintDocumentContent, Copies => 1, PageType => wdPrintAllPages, PrintToFile => 1, PrToFileName => "c:\temp\out.ps" });
If I remove the "PrToFileName", I get the "Print To File" dialog box.
Can anyone point me in the right direction on how to get this to work correctly?
Thanks,
Kirk

In reply to Using Win32::OLE Printing to a file from MS-Word by kirk_patton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.