如何阻止用户使用c# Word Interop编辑Word文档?

发布于 2024-10-02 04:53:35 字数 481 浏览 0 评论 0原文

我的c#应用程序必须填充Word模板并将处理结果保存到另一个文件。我们已被要求锁定新文档以防止任何修改。现在,我尝试过:

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

并保存,但是打开文档时仍然可以编辑,唯一的限制是我们无法保存到同一个文件......这显然不是我想要的。 我需要的是我的文档的完整锁定,即用户无法从 Word 与其进行交互(编辑、取消、添加或重新格式化文本)。 我知道在 Excel 中有一种方法可以锁定工作表的单元格,我为另一个项目做了...Word 中有类似的方法吗?

忘了提:我必须使用Word 2003(所以PIA版本11.0)。

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, i.e. 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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高跟鞋的旋律 2024-10-09 04:53:35

网上有很多关于如何无法真正有效地完成此操作的内容。

如果您确实决定根据 @spender 的评论使用 PDF,这里有一些有用的信息 此处(下载所需软件)此处(需要 C# 逻辑)

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文