package ExcelFileIsProtected; sub ExcelFileIsProtected { my ($path_to_file) = @_; # One argument wait use Win32::OLE; my $xlApp = Win32::OLE->new('Excel.Application'); $xlApp->{DisplayAlerts} = 0; # Open excel file. my $xlBook = $xlApp->Workbooks->Open($path_to_file); my $Sheet1 = $xlBook->Worksheets(1); my $row = 1; my $col = 1; $Sheet1->Cells($row,$col)->{'Value'} = 5; if (Win32::OLE->LastError) { return true; } else { return false; } $xlBook ->Close(); undef $xlBook; } 1;