Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Excel Const - No type library matching error message

by merrymonk (Hermit)
on Dec 06, 2017 at 17:09 UTC ( #1205032=perlquestion: print w/replies, xml ) Need Help??
merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

At the web site https://docstore.mik.ua/orelly/perl4/perlnut/ch23_05.htm there is a description of Win32::OLE::Const.
The 2nd paragraph is
You can either import the constants directly into your namespace as subs that return the constant value, or you can have them returned as a hash reference with the constant name as the key and its value as the value. Here's an example of the former:
use Win32::OLE::Const ("Microsoft Excel");
print "xlExcel5 = ", xlExcel5, "\n";
This produces something like:
xlExcel5 = 39

I had been using this successfully for some time.
However, in October 2012 I started getting No type library matching error messages for the 1st Win32::OLE line above.
I asked the Perl Monks about this and got a number of replies.
One of these was to have the line
use Win32::OLE::Const "Microsoft Excel .* Object Library";
This worked but now has started to fail with the No type library matching error message
Another suggestion in 2012 was to have the following
use Win32::OLE; use Win32::OLE::Const; my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); my $xlcon = Win32::OLE::Const->Load($Excel); foreach $key (sort {$a cmp $b} keys %$xlcon) { print "$key value $xlcon->{$key}\n"; }
This works, which is good.
However, I wondered if any Monk knew:
1. Why the row suddenly started giving these errors as far as I can tell no changes have been made to the system;
2. Why the same version of Perl is continuing to work without any issues on another system;
3. How I could prevent the errors (I appreciate that I probably can use the working Perl however I do not want to do that only to find that this suddenly stops working).

Replies are listed 'Best First'.
Re: Excel Const - No type library matching error message
by poj (Monsignor) on Dec 06, 2017 at 19:09 UTC

    What do you get if you run this on both systems

    #!perl use strict; use Win32::OLE::Const; Win32::OLE::Const->EnumTypeLibs(\&mylib);; sub mylib { return unless $_[1] =~ /Excel/; print join " ",$_[1],$_[4],"\n"; }
    poj
      I got this on my PC
      Microsoft Excel 14.0 Object Library C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE
      Microsoft Excel 14.0 Object Library C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE

      Is that the sort of output you are expecting?
      I will get the Perl run on the 2 other systems tomorrow and post here what is obtained.
        I now have the results of running the test on two different systems with the same version of Perl.
        On the system where the Const variants failed, nothing was printed out.

        On the system where the Const was successful, the following was written out.

        Microsoft Excel 15.0 Object Library C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE
        AdHocReportingExcelClientLib C:\Program Files (x86)\Microsoft Office\Office15\ADDINS\Power View Excel Add-in\AdHocReportingExcelClient.dll
        Microsoft Excel 15.0 Object Library C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE
        AdHocReportingExcelClientLib C:\Program Files (x86)\Microsoft Office\Office15\ADDINS\Power View Excel Add-in\AdHocReportingExcelClient.dll

        From this I gather that there is something missing from the failing system and that this may be something like the dll shown.
        What is the simplest way to correct this? Is it as simple as copying the dll?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1205032]
Approved by beech
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-07-19 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (411 votes). Check out past polls.

    Notices?