Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Win32::OLE and Word

by GrandFather (Saint)
on Sep 27, 2005 at 00:28 UTC ( [id://495237]=note: print w/replies, xml ) Need Help??

in reply to Win32::OLE and Word

Use $Word = Win32::OLE->new ("Word.Application"); rather than $Word = Win32::OLE->GetActiveObject("Word.Application");. I'd guess you had Word running on your test system, but not on the others.

Update: It's not obvious to me why you my $Word = Win32::OLE::Const->Load("Microsoft Word"); as you don't use the constants. In fact you immediately clobber the variable in the next line!

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: Win32::OLE and Word
by Util (Priest) on Sep 27, 2005 at 01:58 UTC

    Best of both worlds:
    Adapted from Win32::ole and MSWord:

    # If Word is already running, then use the existing instance, # and leave it running when we are done. # Otherwise, start a new instance of Word, and close it when # we are done. use strict; use warnings; use Win32::OLE; my $Word; eval {$Word = Win32::OLE->GetActiveObject('Word.Application')}; die "Word not installed: $@" if $@; unless (defined $Word) { $Word = Win32::OLE->new('Word.Application', sub {$_[0]->Quit}) or die "Oops, cannot start Word"; } $Word->{'Visible'} = 1; # If you want to see what's going on

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://495237]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-06-21 10:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.