http://www.perlmonks.org?node_id=454789


in reply to Win32::OLE objects

Hi

I ran your code and added the following:
sub LogInit{ my $appname = $_[0]; my $module = $_[1]; my $apploglevel = $_[2]; $LogObj = Win32::OLE->new('LOGGERHELPER.UILogHelp'); print "Ref is ", ref $LogObj, "\n"; print Win32::OLE->LastError(), "\n" unless ($LogObj); $Log0bj->{LogLevel} = $apploglevel; $Log0bj->{AppName} = $appname; $Log0bj->{Module} = $module; Win32::MsgBox('my log is "'.$LogObj.'"'); return $LogObj;
the Reference is null, and the last error is:

Ref is Win32::OLE(0.1702) error 0x800401f3: "Invalid class string" Can't call method "LogMessage" on unblessed reference at CLUILogger.pm + line 42.
Perhaps you need to import the LOGGERHELPER.UILogHelp constants in the Win32::OLE call?

- j

Replies are listed 'Best First'.
Re^2: Win32::OLE objects
by anselmomh (Initiate) on May 06, 2005 at 19:37 UTC
    When all the code is in the same perl file it all works its only when i moved the logging code to a module that passing hte Win32::OLE object seems to get upset
    perl file --> calls LogInit
    pm file --> creates Win32::OLE object and passes back
    perl file --> calls LogIT passing in the Win32::OLE object that it got back
    pm file --> uses that object to pass it ARGS which logs things
    so basically im not passing Win32::OLE object correctly i guess i just dont know how to fix it :(
      Hi

      Right; is it possible that your 'use Win32::OLE' statement was/is different in your .pl file as opposed to the .pm file? Or had a use Win32::OLE::Const line?

      - j

        The Win32::OLE::Const line was never in the perl file and an older copy that works has the exact same lines for the creation of the object .. there must be something you have to do when passing a Win32::OLE object back and forth between a perl file and a module that im not aware of :(