Ms-Word Ole and multiple independent instances.

Discussion in 'Perl Misc' started by Rudy Van Eeckhout, Sep 20, 2006.

  1. Hello all,

    I do have several perl scrips whicht opens by ole an word instance
    which is used to print a document to a certain printer. Now we noted
    that these documents sometimes appear on the wrong printer. After some
    investiation is did seen next effect.
    First assume next script

    my $Word= Win32::OLE->CreateObject('Word.Application', 'Quit');
    $openWord->{'Visible'} = 0;
    $Word->{ActivePrinter} = "$printer";
    <STDIN> ; #Wait for a cariage return
    print $Word->{ActivePrinter} ."\n" ;

    When i run this script with $printer set to printerA and i do wait to
    give a cariage return until i did run the script in a second form with
    $printer set to printerB. The both script will print as active printer
    printerB. This means that the assingment of Activeprinter is done for
    all instances which are running.

    Even when you try this manualy by opening 2 word sessions you can see
    that the printer changes over the different sessions.

    If you start msword from the command line with the /w option the
    problem disapears.
    Now i can not find out how to do this over perl OLE.

    Is there anybody who knows how to sole this over OLE?

    Kind regards.

    Rudy.
    Rudy Van Eeckhout, Sep 20, 2006
    #1
    1. Advertising

  2. Rudy Van Eeckhout

    Dave Guest

    "Rudy Van Eeckhout" <> wrote in message
    news:...
    > Hello all,
    >
    > I do have several perl scrips whicht opens by ole an word instance
    > which is used to print a document to a certain printer. Now we noted
    > that these documents sometimes appear on the wrong printer. After some
    > investiation is did seen next effect.
    > First assume next script
    >
    > my $Word= Win32::OLE->CreateObject('Word.Application', 'Quit');
    > $openWord->{'Visible'} = 0;
    > $Word->{ActivePrinter} = "$printer";
    > <STDIN> ; #Wait for a cariage return
    > print $Word->{ActivePrinter} ."\n" ;
    >
    > When i run this script with $printer set to printerA and i do wait to
    > give a cariage return until i did run the script in a second form with
    > $printer set to printerB. The both script will print as active printer
    > printerB. This means that the assingment of Activeprinter is done for
    > all instances which are running.
    >
    > Even when you try this manualy by opening 2 word sessions you can see
    > that the printer changes over the different sessions.
    >
    > If you start msword from the command line with the /w option the
    > problem disapears.
    > Now i can not find out how to do this over perl OLE.
    >
    > Is there anybody who knows how to sole this over OLE?
    >
    > Kind regards.
    >
    > Rudy.
    >


    I think this is more of a Word issue than a perl issue, and I suspect
    (without looking into it) that activeprinter is a global setting for word
    rather than a per-document setting.

    In the example script you give you set the activeprinter early, then wait
    for input and then print to it. If instead you set the activeprinter just
    before printing you would have fewer problems. You might still get the odd
    glitch if two scripts are running concurrently and both try to change the
    setting at nearly the same time, but this would happen far less often than
    the current issue which is that you set the printer, wait (during which time
    another process may set it to something else) and then print.

    Dave
    Dave, Sep 21, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick.O.Ige

    Ole ole

    Patrick.O.Ige, Jul 16, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    477
    Patrick.O.Ige
    Jul 16, 2006
  2. Drew Pihera
    Replies:
    0
    Views:
    622
    Drew Pihera
    Feb 4, 2004
  3. John Wohlbier
    Replies:
    2
    Views:
    357
    Josiah Carlson
    Feb 22, 2004
  4. Replies:
    1
    Views:
    242
    Dennis Lee Bieber
    Feb 20, 2008
  5. Lance Hoffmeyer
    Replies:
    0
    Views:
    230
    Lance Hoffmeyer
    Nov 17, 2003
Loading...

Share This Page