How do I determine the type of a Win32::OLE object? I know about ref() and
Win32::OLE->QueryObjectType but these only tell me the class and type lib. I
can determine if it is a HASH or SCALAR reference but what I really need to know
is if it is an Object or Collection.
Here's some code for returning object type:
my $type = ref $thing
or return;
if ($type eq 'Win32::OLE') {
my ($lib, $class) = Win32::OLE->QueryObjectType($thing);
$thing =~ /(=\w*)\b/;
$type.= "$1:$lib.$class";
}
But i's just not enough. I tried this:
if (defined $object->{Count})
but that returns and error if the object is not a Collection.
I then used this:
foreach my $key (keys %$object) {
if ($key eq 'Count') { # we have a collection
#do something with it
last;
}
}
That doesn't cause an error but it's not very eligant. There must be a function
that tells me the object type!
I get the same problem when I try to get the Name of an object. Nearly all ADO
objects have a Name attribute but the error object doesn't so calling:
$item->{Name} or $item->Name results in an error:
Win32::OLE(0.1101) error 0x80020006: "Unknown name"
I tried this:
if (defined $item->{Name}) {
but got then got this:
Win32::OLE(0.1101) error 0x8002000e: "Invalid number of parameters"
in METHOD/PROPERTYGET "Name" at ....
I need to know if an object has an attribute so that it doesn't complain when I
examine it.
--
Simon Oliver
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]