标签:
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 }
标签:
原文地址:http://www.cnblogs.com/lyosaki88/p/5000106.html