I'm using automation to open documents in Word. Sometimes I need to open document in Read mode ON:
var
WordDocument: _Document;
WA: TWordApplication;
begin
WA := TWordApplication.Create( nil );
WA.OnQuit := DocumentClose;
WA.Connect;
WordDocument := Wa.Documents.Open( FileName, EmptyParam, true {ReadOnly}, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam );
But user can off the Read mode in opened document:
How can I handle this in OnQuit
event in procedure DocumentClose
?
In DocumentClose
I want to know if document is in read mode or not.
I do not have any solution because I did not have enough experience with it. So, I need your suggestions, advices about it. Sorry for my English and if I have to add more informations, please let me know. Thanks
UPDATE
I've tried to read protection type, but it's always return the first case. So, when document opening as ReadOnly isn't protected as wdAllowOnlyReading. Some documents can be protected with password, but there is not problem with it.
const
wdAllowOnlyReading: Longword = $00000003;
wdNoProtection: Longword = $ffffffff;
var
ProtectionType: TOleEnum;
begin
ProtectionType := WordDocument.ProtectionType;
case ProtectionType of
wdNoProtection : Showmessage('NoProtection');
wdAllowOnlyReading: Showmessage('ReadOnly');
end;
end;