Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Unexpected Excel TypeLib error

by merrymonk (Hermit)
on Oct 12, 2015 at 08:13 UTC ( [id://1144489]=perlquestion: print w/replies, xml ) Need Help??

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

Another mystery of Excel.
I have had the following line of Perl for sometime in my Perl applications and modules used by a number of versions of Excel
use Win32::OLE::Const 'Microsoft Excel';
However a user is running Excel 2013 and gets the following message
No type library matching "Microsoft Excel" found at module name line 77
Win32::OLE(0.1703): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/perl5/site/lib/Win32/OLE/Const.pm line 45
Even with the message the application appears to run without any problems.
Therefore I have removed this line and it appears to run in my Excel 2010 version without problems.
Is is safe simply to remove this line (I have the same modules running in other versions of Excel)?

Replies are listed 'Best First'.
Re: Unexpected Excel TypeLib error
by xiaoyafeng (Deacon) on Oct 12, 2015 at 08:35 UTC

    if you don't use any Excel constants in the applications , you can simply remove this line. but if you does, I suggest you upgrade Win32::OLE to at least 0.1710. In that version, it seems the author fix this problem.





    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

      Thank you for all the helpful replies. As I suspected I will have to experiment to find out what I can safely remove.
      I guess I have some hopes that it will not be too difficult since the application runs even with the error message.

      A small correction: but if you does... should be but if you do...

      Update: one more change: the author fix... should be the author fixed... There are also some punctuation errors but they are probably due to fumble fingering as we all do--especially we "hunt and peck" typists!

      Your English is generally excellent--these suggestions are per your request.

        I meet same issue on Excel2016, do you fixed the problem? how to upgrade the WIN32::OLE module version to 0.1710? Thanks.
Re: Unexpected Excel TypeLib error
by nikosv (Deacon) on Oct 12, 2015 at 10:57 UTC
Re: Unexpected Excel TypeLib error
by dasgar (Priest) on Oct 12, 2015 at 14:58 UTC

    If you look at the examples in Win32::OLE::Const, you'll see that your use statement needs to be more like:

    use Win32::OLE::Const ('Microsoft Excel 8.0 Object Library');

    Of course, the problem with that is that your code is now expecting only one version of Excel. The '8.0' would need to be changed to support another version of Excel. One way around this that I have done is to use the following line instead:

    use Win32::OLE::Const "Microsoft Excel .* Object Library";

    This will load the Excel object library for whichever version of Excel is installed - and will hit issues if Excel is not installed. Just keep in mind that there is a chance that Microsoft may change/add/remove constants between versions of Excel. Also, you might want to keep in mind that other behaviors can change between Excel versions that could seriously impact your code - such saving the spreadsheet, which requires different code for Excel 97 and newer Excel versions.

Re: Unexpected Excel TypeLib error
by Anonymous Monk on Oct 12, 2015 at 08:19 UTC

    Is is safe simply to remove this line (I have the same modules running in other versions of Excel)?

    No.

    That line is supposed to import excel constants, if it doesn't import the constants they won't be defined, and your program can't use them

    But if your program doesn't actually use them ....

    So its up to you :)

    site:perlmonks.org No type library matching "Microsoft Excel"

      Constants are useless without an app (like excel), so use an ole instance to get the constants, the best way to get constants, direct quote from the docs/Win32::OLE::Const

      use Win32::OLE; use Win32::OLE::Const; my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); my $xlcon = Win32::OLE::Const->Load($Excel); ... $xlcon->{xlMarkerStyleDot} ...
Re: Unexpected Excel TypeLib error
by Anonymous Monk on May 18, 2016 at 03:37 UTC

    Issue: No type library matching "Microsoft Excel" found at module name line 77 Win32::OLE(0.1703): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/perl5/site/lib/Win32/OLE/Const.pm line 45

    Solution:

    This issue arise in windows 7, 64 bit with MS office 2013 with 64 bit, if you remove the use Win32::OLE::Const 'Microsoft Excel' line, you could not be able to read the excel file

    so to avoid this error, use below standard code

    use Win32::OLE::Const '.*Excel';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1144489]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-18 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found