Mark S Pryor said:
Domenico,
can
There are 2 methods:
Directly enumerating the registry keys under
hkcr\typelib for this excel library (Tie::Registry)
or
use Win32::OLE;
my $Obj = Win32::OLE->new('TLI.TypeLibInfo', \&OleQuit)
|| die("could not create Obj\n");
The methods and propterties of the TypeLibInfo (see OleView.exe)
object will get the GUID and help string for your object.
I don't have a complete Perl example for the above, but if you have
ActivePerl, there should more than enough written by Jan D.
hth,
msp
Did I find a bug in ActivePerl 5.8?
Can anyone run this code without it throwing fatal errors when
the TypeLib helpstring misses? This concept won't work unless
we can handle fatal OLE errors
#!/usr/bin/perl
#
# Author: unknown
# script: ExcelGUID.pl
# Description: loop over possible excel libnames till we find one
# keywords: typelib progid test perl
# Date: 12/30/03
use strict;
use warnings;
#use Win32;
use Win32::OLE qw(in with);
use Win32::OLE::Const ;
# I tried all variations of key Warn that let
# the script continue
Win32::OLE->Option(Warn => sub {goto CheckError});
#use Carp; # qw(cluck)
# Microsoft Excel 9.0 Object Library
my $Lib = '';
#use Data:
umper;
#my $Consts;
my @excel;
my $vers = '';
$| = 1;
#
# i have version 9 installed
foreach $vers (7 .. 11) {
$Lib = "Microsoft Excel $vers\.0 Object Library";
print "Lib= $Lib \n";
#cluck "time to cluck" if Win32::OLE->LastError;
my $Consts = Win32::OLE::Const->LoadRegTypeLib( $Lib);
print ref( $Consts), "\n";
print "ok found it, exiting \n";
# @excel = keys %$Consts;
#print "Length=$#excel \n";
last;
CheckError:
print "normal error \n";
next
}
exit(0);
__END__