Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Does Win32::OLE suck?

by LameNerd (Hermit)
on Jan 24, 2003 at 23:25 UTC ( [id://229743]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Does Win32::OLE suck?
by batkins (Chaplain) on Jan 24, 2003 at 23:44 UTC
    Yes, it sucks, but only because OLE does. :)

    Seriously, Win32::OLE isn't too bad. It doesn't need much documentation because it has different capabilities depending on the object created with it. Visual Basic code can be easily converted to Win32::OLE code. There was a section in Learning Perl on Win32 about that very topic.

    Bill

      Do you really think OLE/COM is that bad? Seems to be a pretty useful technology to me.

      --- demerphq
      my friends call me, usually because I'm late....

Re: Does Win32::OLE suck?
by grantm (Parson) on Jan 25, 2003 at 08:43 UTC
    Will I be forced to learn how to code Visual Basic?

    You might have to learn how to read it at least. One way to get going with Win32::OLE for MS Word is to use the macro record facility in Word to record some keystrokes (eg: edit-select all); then hit Alt-F11 to open up the macro editor; the convert VB to Perl by changing '.' to '->', putting curly braces around property names and putting $ signs in the right places :-)

    To be pedantic, the macro language in Word is VBA which is different from 'full-blown' VB and different again from VBScript.

Re: Does Win32::OLE suck?
by Mr. Muskrat (Canon) on Jan 24, 2003 at 23:42 UTC

    Win32::OLE is supposed to be easy to use and understand? Only if M$ had made OLE easy to use and understand!

    OTOH, Win32::OLE is not all that difficult to learn or use. Have you tried reading the fine documentation that comes with it?

Re: Does Win32::OLE suck?
by ibanix (Hermit) on Jan 25, 2003 at 09:27 UTC
    Win32::OLE is the only way to write perl code that interfaces with Active Directory (see: ADSI) at the moment.

    You should keep this wise saying in mind:
    There is no glory in the easy victory.

    ibanix

    $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
Re: Does Win32::OLE suck?
by Zero_Flop (Pilgrim) on Jan 25, 2003 at 05:55 UTC
    As mentioned WIN32::OLE only sucks as much as OLE sucks!

    I actually use it all the time. What you have to understand is that
    you have access to all the OLE that would be availabe in VB. If you
    can not "select all" in win32::ole you will not be able to do it in
    VB.

    to select all you the OLE is "Selection.WholeStory" or perlish Selection->WholeStory

    If you need some tips let me know
Re: Does Win32::OLE suck?
by Nitrox (Chaplain) on Jan 25, 2003 at 16:43 UTC
    When it comes to threading, Win32::OLE still has some major issues. There's a webpage on the AS site that lists Win32::OLE as being thread-safe (read it HERE), which should be taken with a grain of salt.

    As it turns out, Win32::OLE is only thread safe when "used in a process that hosts multiple Perl interpreters, each compiling their own scripts".

    So when it comes to an embedded Perl project I've been working on which utilizes 5.8 threads, I've found that a COM object created in one thread can not be shared (whether by 'cloning' or by explicitly calling share()) with other threads.

    I've submitted this bug to the author so hopefully we'll see a new release soon. Unfortunately he has listed it as a simple "Enhancement" request, which I tend to disagree with.

    -Nitrox

Re: Does Win32::OLE suck?
by LameNerd (Hermit) on Jan 25, 2003 at 00:28 UTC
    thanks for your replies. But the documentation does not seem to cover
    doing a select all operation with MS Word. If I am wrong please
    point me in the right direction.
    Thanks

      Win32::OLE only offers you the method to control another application, but it does not document what you can do with the other application. The Win32::OLE manpage has (I think I remember) a list of common links on where to obtain documentation for the most used programs (MS Office). A search with Google will turn up a lot of Visual Basic code that can be ported almost verbatim to Perl.

      ' VB Code, written without either VB or MS Word available to check set objWord = CreateObject("Word.Application") objWord.DocumentNew() objWord.Document.Text = "Hello World" objWord.Document.SelectAll() # Perl code use strict; my $word = Win32::OLE->new('Word.Application'); $word->DocumentNew(); $word->{Document}->{Text} = "Hello World"; $word->{Document}->SelectAll;
      perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://229743]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found