Is there any method within Perl which would allow me to get the object in a read only mode, so as to avoid the dialog that pops up if the file is locked by another user?
$document = Win32::OLE->GetObject("$docFile")
or die "can't open $docFile";
That's because you're doing it wrong. GetObject
just opens an object with the default behavior. You should create the Word.Application
object:
my $word = Win32::OLE->new( 'Word.Application' );
Then use the Documents
collection Open
method with the named parameter ReadOnly
. Like so:
$doc = $word->Documents->Open( { FileName => $document_path,
, ReadOnly => 1
} );
Read http://msdn.microsoft.com/en-us/library/bb216319.aspx for the syntax for Documents.Open
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With