C#调用Permission实现对office文档权限设置

C#添加Microsoft.Office.Core组件,调用Permission实现对office文档权限设置,调用permission.Add(string userid, property, expirationTime)时,expirationTime设置无效,格式为:
object expirationTime;
DateTime testtime=DateTime.ParseExact("2015/12/26","yyyy/MM/d",System.Globalization.CultureInfo.InvariantCulture);expirationTime = (object)testtime;
欲将时间期限设置为2015/12/26,但效果是文档的读写权限设置成功,时间设置不起作用。跪求正确的时间格式啊

2个回答

这是我的代码:
object MYNOTHING = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document book;
Microsoft.Office.Interop.Word.Application m_woapp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document book = m_wobooks.Open(filepath, MsoTriState.msoFalse, OBFALSE, OBFALSE, MYNOTHING, MYNOTHING, MYNOTHING,MYNOTHING, MYNOTHING, MYNOTHING, MYNOTHING, MYNOTHING, MYNOTHING, MYNOTHING, MYNOTHING, MYNOTHING);
Microsoft.Office.Core.Permission permission = book.Permission;
object expirationTime;
DateTime testtime = DateTime.ParseExact("2015/12/26", "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture);
expirationTime = (object)testtime;
permission.Add("user@.com", MsoPermission.msoPermissionChange, expirationTime);

不报错,读写权限设置成功了,但expirationTime没起作用,急求时间写法啊

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐