Greetings!
I have a script that mucks around in Excel, which I've been using since Office 2000. Suddenly and tragically, I am having issues with Excel 2013 users. I need to make the workbook visible, otherwise when I save the Excel file, the workbook will be hidden when the user tries to open it. I have used the code below successfully for years to accomplish this. I have marked the offending line below in the code. When this is used with Excel 2013 on Win7 x64, I get the following error:
Win32::OLE(0.1712) error 0x8002000b: "Invalid index" in METHOD/PROPERTYGET "Windows" at blah.pl line 91. Can't use an undefined value as a HASH reference at blah.pl line 91.
Has anyone else run into this, or have any suggestions?
use strict;
use Win32::OLE qw(with);
use Win32::OLE::Const 'Microsoft Excel';
sub open_sheet {
my $file = shift;
my $workbook = Win32::OLE->GetObject( "$file" )
|| die "Could not locate $file.\n";
my $excelApp = $workbook->{Application};
$excelApp->{Visible} = 1;
# ****this next line no longer works in Excel 2013****
$excelApp->Windows( $workbook->{Name} )->{Visible} = 1;
# ^^^^bad!
....
}
Thanks!