Thanks for that. I looked in the link and found enum for all objects and thought that may give what I wanted. Therefore I wrote some Perl (below) to test it. Unfortunately, the count was always zero no matter how many Excel files were open. Googling for Excel and Enum, I did find a site where someone was trying gain access to a file by requesting a handle to it. I thought that this may give what I wanted on the basis that it would only return a handle if the file was there but not opened. I can easily test if a file is there – if it is not it cannot be open. This is also in the Perl code below. Unfortunately this did not work either since it always returned a handle and if the file was not open, it opened Excel with a ‘blank’ screen. Can anyone give me a clue as to what to do next?
use OLE;
use Win32::OLE::Const "Microsoft Excel";
use strict "vars";
my ($Count, $file, $ML);
$Count = Win32::OLE->EnumAllObjects(sub {
my $Object = shift;
my $Class = Win32::OLE->QueryObjectType($Object);
printf "# Object=%s Class=%s\n", $Object, $Class;
});
print "count <$Count>\n";
$file = "C:\\abcd.xlsx";
$ML = Win32::OLE->GetObject($file)
or print "can't get a handle on '$file'";
print "$ML\n";
|