Error with Win32 :: OLE-> new ("Excel.Application") and filename with unicode characters

I would like to open an excel file on Cygwin that has it ü

in the filename, but I get the exception:

OLE exception from "microsoft Office Excel":

      

Here's the program I'm using:

use 5.014;
use warnings;
use strict;
use Win32::OLE qw(CP_UTF8);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Enum;

$Win32::OLE::Warn = 2;
$Win32::OLE::CP = CP_UTF8;

my $excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;});   

my $filename = "/cygpath/c/fooü.xls";
$filename = `cygpath -wa '$filename'` or say "Damned";

my $book = $excel->Workbooks->Open({ FileName => $filename, ReadOnly => 1}) or return;

      

What can I do to encode the filename correctly? I've already tried encode('utf8', $filename)

, and cp1252

and latin1

.

+3


source to share





All Articles