tags:

views:

331

answers:

1

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";
+4  A: 

That's because you're doing it wrong. GetObject just opens an object with the default behavior. You should create the Word.Application ojbect:

 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

Axeman
I will experiment with that.Thank you.
EvilTeach
A very high quality answer.Thank you.
EvilTeach