Quantcast
Channel: Delphi Forum - Delphi Programming Kings of Code - Delphi Programming
Viewing all articles
Browse latest Browse all 173

Word OLE automation and read-only files

$
0
0
Hi,

If you open a read-only Word document or a document from email attachment or something else the Word considers that should not be edited, the document opens in some Read-only mode. If you wish to edit this file, there is an option in View->Edit Document. I had a problem how to enter this edit mode via OLE automation from Delphi. After a lot of time, I discovered ReadingLayout property. For example:


Code:
var
WordApplication : Word_TLB._Application;
WordDocument : Word_TLB._Document;
begin
WordApplication := CoWordApplication.Create;
WordDocument:=WordApplication.Documents.Open('Test.docx',EmptyParam,True,EmptyPa​ram,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam​,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
WordDocument.ActiveWindow.View.ReadingLayout:=False;
...

Off course, read-only mode can be disabled in Word options, but I can not know in advance whether someone has disabled this option or not Smile

Best regards!
 

 

 

 

 

 

 

Viewing all articles
Browse latest Browse all 173

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>