I know Perl and I’ve worked some with VBA, so I can give this a shot — but I haven’t used Win32::OLE, so you may have to experiment with this a bit.
<b>Question 1: How to open in read-only mode</b>
The prototype for Workbooks.Open, from <a href=”http://msdn2.microsoft.com/en-us/library/aa195811(office.11).aspx”>Microsoft’s VBA reference</a> is:
<i>expression</i>.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)
In VBA, you’d be able to do:
In Perl, you can either pass undef for UpdateLinks to pass it, or use a named parameter in a hash. So I’m guessing it would be something like:
my $Book = $Excel->Workbooks->Open(FileName => $file, ReadOnly=>1); #maybe?
This is according to <a href=”http://search.cpan.org/~jdb/libwin32-0.28/OLE/lib/Win32/OLE.pm”>Win32::OLE on CPAN</a>.
So basically, if you set ReadOnly to true, I’m guessing it won’t pop up an alert to open in read-only mode.
<b>Question 2: Reading the date</b>
In VBA, the string representation of a date cell always seems to be of mm/dd/yyyy format, regardless of how the cell’s formatting is set. If this is the case, you can use a simple regex to convert that into a Perl-style date:
# assume $dateStr has the date in string format, from OLE
$dateStr =~ /(\d+)\/(\d+)\/(\d+)/; # matches d+/d+/d+
$dateMonths = $1;
$dateDays = $2;
$dateYears = $3;
$date = timelocal(0, 0, 0, $dateDays, $dateMonths , $dateYears );</pre>