码迷,mamicode.com
首页 > 其他好文 > 详细

对Office文档进行授权

时间:2015-11-27 12:47:58      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1             Microsoft.Office.Interop.Word.ApplicationClass app = new Microsoft.Office.Interop.Word.ApplicationClass();
 2             object filePath = @"D:\auth.docx";
 3             object missing = System.Reflection.Missing.Value;
 4             Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(ref filePath);
 5             try
 6             {
 7                 doc.Activate();
 8 
 9                 Microsoft.Office.Core.Permission permisson = doc.Permission;
10                 Console.WriteLine("已有授权数:" + permisson.Count);
11                 for (int i = 1; i <= permisson.Count; i++)
12                 {
13                     string userId = permisson[i].UserId;
14                     Console.WriteLine(userId);
15                 }
16 
17 
18                 permisson.Add("qx", Microsoft.Office.Core.MsoPermission.msoPermissionFullControl, null);
19 
20 
21                 doc.Save();
22             }
23             catch (Exception ex)
24             {
25                 Console.WriteLine(ex.Message);
26             }
27             finally
28             {
29                 doc.Close();
30                 app.Quit();
31             }
View Code

 

对Office文档进行授权

标签:

原文地址:http://www.cnblogs.com/lyosaki88/p/5000106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!