I once again appeal to the Monks for enlightenment.

I am a relative newbie to Perl, but have been learning for a few months. I have written a fair amount of Perl code thus far, and have now attacked the most ambitious project yet. I am on the verge of admitting defeat and going over to the dark side and using VB.

I have installed the OLE PPM and tested many examples for controlling Word and Excel without problems. I thought I had this OLE stuff groked and could write automation code.

I have this non-Microsoft application with a brand new, beta OCX interface, with VB examples of controlling it. I have translated many calls from the VB examples to Perl, to no avail.

I have posted many detail questions here, and received valuable answers. I can now create my obj server, query object type and get the proper response, and destroy the object. But no calls to any function or method succeeds. I have spent many hours on the web studying tutorials and sample code for Microsoft and lotus applications.

I am starting to suspect that there is some significant deficit wrt support for OCX's vs. VB that I am somehow missing. This morning while surfing the web yet again for samples and documentation I came across a statement to the effect that Perl OLE does not support OCX. This threw me into panic.

The statement was without further elaboration, but caused me to think that the reason all my calls are failing is not that I am doing something wrong, but rather that there is something about the objects and methods I am calling that makes them different from similar appearing calls to, for example, Excel.

Perhaps there is some aspect of this that Win32::OLE isn't supporting, or perhaps there is something fundamentally broken in the application itself that locks it in to being called from VB.

I need enlightenment from the Monks, show me the error of my ways. I have used OLEView and the perl Browser-OLE to examine the objects. I have looked at them in the machines registry. I am at a loss as to why my calls fail.

For example: The file is HALi.OCX. The library is HALiCnt. There is a class CModes, which contains a property Count as a readonly Long. There is a Class HALi which contains a property Modes as _CModes. My server is HALiCnt.HALi. By everything I have read, the statement:

$HALi = Win32::OLE->new('HALiCnt.HALi')
my $c = $HALi->Modes->Count();
should return the number of Modes defined, which is in actuality known by me to be 5. Instead I get "Can't call method Count on undefined value".

I have experimented for hours with many variations of the call, and with many other calls of a similar nature in the library. Nothing! Nada!

Am I overlooking something fundamental in Perl's support of OLE automation?? Must I tuck my tail and move with the masses to VB to access this application?

Please enlighten me.

Nathan


In reply to Perl for OLE & OCX by wa4otj

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.