简体   繁体   中英

How to prevent user to edit Word Document wit c# Word Interop?

My c# application must fill a Word template and save the processing result to another file. We've been requested to lock the new document to prevent ANY modification. Now, I have tried with:

wordDoc.Protect(
            Word.WdProtectionType.wdAllowOnlyReading,
            ref oMissing,
            ref password,
            ref oMissing,
            ref oMissing);

and save, however when opened the document can still be edited, the only constraint is that we cannot save to the same file... wich is obviously not what i'm looking for. What I need is a complete LOCK of my document, ie user cannot interact (edit, cancel, add or re-format text) with it from Word. I know in Excel there's a way to lock the sheet's cells, I did for another project... Is there something similar in Word?

Forgot to mention: I must use Word 2003 (so PIA version 11.0).

There is a bunch of stuff online about how this cannot really be done with any effectiveness.

If you do decide to use PDF for this per @spender's comment, there is some useful info here (download required software) and here (required C# logic) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM