> Dear All,
> 
> I am having an XLSX file in server and my OS in Win7. The first open
> statement is working fine in which we have give the actual file name.
> 
> 2nd open function is not working where we have given the file name as
> variable.
> 
> Please help in resolving this error.
> 
> 
> use Win32::OLE;
> use Win32::OLE qw(in with);
> use Win32::OLE::Variant;
> use Win32::OLE::Const 'Microsoft Excel';
> $emfile="02896787";
> $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
>        Win32::OLE->new('Excel.Application');
> $Excel->{'Visible'} = 0;        #0 is hidden, 1 is visible
> $Excel->{DisplayAlerts}=0;    #0 is hide alerts
> my $mBook = $Excel->Workbooks->Open
>              ('\\\\pchns2003z\SPECIALIZED_SERVICES_I\AnI\Embase\Pull
> files_IRNPD\inventory\02896787.xlsx'); # open Excel file
> 
> my $meBook = $Excel->Workbooks->Open
>              ("\\\\pchns2003z\\SPECIALIZED_SERVICES_I\\AnI\\Embase\\Pull
> files_IRNPD\\inventory\\$emfile.xlsx"); # open Excel file


There is no problem with the variable interpolation or backslashes. 
The two strings are the same:

my $emfile="02896787";

my $mBook = 
'\\\\pchns2003z\SPECIALIZED_SERVICES_I\AnI\Embase\Pullfiles_IRNPD\inve
ntory\02896787.xlsx';

my $meBook = 
"\\\\pchns2003z\\SPECIALIZED_SERVICES_I\\AnI\\Embase\\Pullfiles_IRNPD\
\inventory\\$emfile.xlsx";

print "$mBook\n$meBook\n";

print ($mBook eq $meBook ? "the same" : "different");


The problem lies elsewhere. If you ask Excel to open the same file in 
two instances at the same time it will complain that it's already 
open.

Try to open a different file :-)

Jenda
===== je...@krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to