in reply to Re^2: Getting an exception while reading excel file using Win::OLE from a current directory
in thread Getting an exception while reading excel file using Win::OLE from a current directory
Only post a SSCCE. The problem is that OLE::Win32 will not save to a path with forward slashes so you need to convert / to \\ as I showed here.
poj#!perl use strict; use warnings; use Win32::OLE; use Cwd; $Win32::OLE::Warn = 3; # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); my $dir = getcwd(); my $excelfile = 'Parameters.xlsx'; my $Book = $Excel->Workbooks->Open($dir."\\".$excelfile) or die Win32::OLE->LastError(); # do work $dir =~ s!/!\\!g; $Book->SaveAs($dir."\\".'updated_'.$excelfile); $Book->Close;
|
|---|