I'm working with MS Word files use TWordApplication. I need show message when document was changed by user, but when document is ReadOnly then message shouldn't be show.
I have problem when open readonly document and then user can select View - Edit document and made some changes. In this case I need to show message but property ReadOnly of document did not change.
How can I handle action when user enable edit the document?
I haven't any idea, please suggest me.
var
LWordApp: TWordApplication;
LWordDoc: _Document;
LProtectionType: TOleEnum;
begin
LWordApp:= TWordApplication.Create( nil );
LWordApp.OnQuit := DocumentClose;
LWordApp.Connect;
...
LWordDoc:= LWordApp.Documents.Open(АFileName, // FileName
EmptyParam, // ConfirmConversion
EmptyParam, // ReadOnly
EmptyParam, // AddToRecentFiles
EmptyParam, // PasswordDocument
EmptyParam, // PasswordTemplate
EmptyParam, // Revert
EmptyParam, // WritePasswordDocument
EmptyParam, // WritePasswordTemplate
EmptyParam, // Format
EmptyParam,
EmptyParam
);
LProtectionType := LWordDoc.ProtectionType;
if AProtectionPassword <> '' then
begin
if LProtectionType <> wdNoProtection then
Doc.Unprotect(AProtectionPassword);
end;
LWordApp.Visible := True;
LWordDoc.Close(tmpSaveIT, EmptyParam, EmptyParam);
LWordApp.Disconnect;
LWordApp.Quit;
end;
procedure DocumentClose(Sender: TObject);
begin
ShowMessage("Hello");
end;