Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Over a minute to do: use Win32::OLE::Const 'Microsoft Excel';

by BrowserUk (Pope)
on Sep 10, 2004 at 12:59 UTC ( #390045=note: print w/ replies, xml ) Need Help??


in reply to Over a minute to do: use Win32::OLE::Const 'Microsoft Excel';

Looking at your profile output it shows that Win32::OLE::Const::_Typelib is being called 538 times. Presumably, once each for 538 imported constants. The pod shows an alternative syntax that gives you back a hash of the constants rather than exporting each as a constant sub. It's possible, though I cannot test it here, that using the alternate syntax mught take less time?

From Win32::OLE::Const pod:

The first example imports all Excel constants names into the main name +space and prints the value of xlMarkerStyleDot (-4118). use Win32::OLE::Const ('Microsoft Excel 8.0 Object Library'); print "xlMarkerStyleDot = %d\n", xlMarkerStyleDot; The second example returns all Word constants in a hash ref. use Win32::OLE::Const; my $wd = Win32::OLE::Const->Load("Microsoft Word 8.0 Object Librar +y"); foreach my $key (keys %$wd) { printf "$key = %s\n", $wd->{$key}; } printf "wdGreen = %s\n", $wd->{wdGreen}; The last example uses an OLE object to specify the type library: use Win32::OLE; use Win32::OLE::Const; my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); my $xl = Win32::OLE::Const->Load($Excel);

It might even be, but again I cannot test this guess, that using the third form above would only import a subset of available constants applicable to excel?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon


Comment on Re: Over a minute to do: use Win32::OLE::Const 'Microsoft Excel';
Select or Download Code
Re^2: Over a minute to do: use Win32::OLE::Const 'Microsoft Excel';
by spikey_wan (Scribe) on Sep 13, 2004 at 12:49 UTC
    After a lot of fiddling about, I have found 2 things that make a difference.

    1. Remove the network cable from my PC. Then the 2 line script runs in ~5 seconds.

    2. Modify C:\Perl\site\lib\Win32\OLE\Const.pm, and change this line:
    return unless -f $filename || $filename !~ /^\w:\\.*\.(exe|dll)$/;
    to this:
    return unless $filename !~ /^\w:\\.*\.(exe|dll)$/;
    and the 2 liner runs almost instantaneously.

    Should I just do the second fix, and not worry about it, or is there a 'proper' way to sort this out?

    Thanks,
    Spike.

      ... or is there a 'proper' way to sort this out?

      I'd certainly apply the second method, and then report the problem to ActiveState.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-08-23 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls