错误保护共同撰写的文档 [英] Error protect document being co-authored

查看:80
本文介绍了错误保护共同撰写的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

b $ b我在单词2010中的单词addin有问题。


addin处理特殊类型的文档和支持文档部件的自动刷新。通常,文档受到保护。仅在自动刷新期间,文档在短时间内不受保护。


一切正常。现在,用户开始通过SharePoint共享文档,并开始与共同创作一起工作。  此时,我注意到文件保护丢失了。在调查后我发现,保护
方法会出现以下异常:


Protect方法或属性不可用,因为此命令是在共同撰写的文档中不可用。 HResult -2146823683


Unprotect方法可以毫无问题地运行。奇怪的是,如果我尝试在相同的情况下手动保护文档,请使用开发者 - >限制编辑 - > "限制格式和编辑"任务窗口 - >单击"是,
开始执行保护",启用文档保护。我尝试使用"记录宏"记录此操作。功能。 VBA代码与我的C#代码类似,并且得到相同的错误。因此,只需手动点击任务窗格
按钮即可。


是否有人知道如何通过代码保护文档?是否有解决方法?


提前感谢您的帮助!


最好的问候

Dirk Loeb




解决方案


VBA代码似乎类似于我的C#代码和 得到相同的错误。因此,只需手动点击任务窗格按钮即可。


您好Dirk Loeb,


您能否发布您的信息C#代码和VBA代码在这里,以便我们可以确定您的代码是否存在问题?如果您可以使用有关您提到的加载项的更多信息,那会更好。


要保护C#代码中的word文档,您可以按照本文档中的代码示例进行操作:


http:// msdn .microsoft.com / zh-CN / library / ms178793(v = vs.100).aspx

 Globals.ThisAddIn.Application.ActiveDocument.Protect (
Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading,
false," password",false,false);

我刚才使用带有Office 2010的Win7 X64测试。我使用VS2012创建了一个Word加载项项目,在此项目中,我从ToolBox添加了一个功能区,然后将一个Button拖到功能区中。双击Button,然后将上面的代码粘贴到其中。在
构建项目之后,我创建了一个示例单词2010文档,单击我创建的按钮,然后保存文档。


当我将此文档上传到sharepoint网站并与其他人共享时,我可以看到该文档受到保护。它并没有像你一样遗失。它也适用于Office 2013.


希望这对您有帮助。



Hi,
I have a problem with my word addin in word 2010.

The addin handles a special type of documents and support the automatic refresh of document parts. Usually, the document is protected. Only during automatic refresh, the document gets unprotected for a short time.

Everything works fine. Now the users start to share the documents via SharePoint and start to work with co-authoring.  At this point, I've noticed that the document protection got lost. After investigation I found out, that the protection method get the following exception:

The Protect method or property is not available because this command is not available in documents that are being co-authored. HResult -2146823683

The Unprotect method works without any problem. Curiously, if i try to protect the document manually in the same situation, using Developer -> Restrict Editing -> "Restrict Formatting and Editing" Taskpane -> Click "Yes, Start Enforcing Protection", the document protection is enabled. I tried to record this action using "record macro" function. The VBA code seems similar to my C# code and get the same error. So only the manual click on the taskpane button works.

Does anyone has an idea how I can protect the document via code? Is there a workaround?

Thanks in advance for your help!

Best Regards
Dirk Loeb


解决方案

The VBA code seems similar to my C# code and get the same error. So only the manual click on the taskpane button works.

Hi Dirk Loeb,

Could you please post your C# code and the VBA code here so that we can make sure if it's the problem with your code? That'll be better if you could give use some more information about the add-in you mentioned.

To protect the word document in C# code, you could follow the code example in this document:

http://msdn.microsoft.com/en-us/library/ms178793(v=vs.100).aspx

Globals.ThisAddIn.Application.ActiveDocument.Protect(
    Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading,
    false, "password", false, false);

I just had a test with Win7 X64 with Office 2010. I created a Word Add-In project with VS2012, in this project I added a Ribbon from the ToolBox, then dragged a Button into the Ribbon. Double clicked the Button, and paste the above code in it. After building the project, I created a sample word 2010 document, clicked the button I created, then saved the document.

When I uploaded this document to the sharepoint site, and shared it with other people, I could see that the document is under protection. It was not missing as yours. It also works fine for Office 2013.

Hope this will help you.


这篇关于错误保护共同撰写的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆