XiaoHui.Net 笑汇程序员论坛.Net 讨论区

   C#中如何打开带有密码的OFFice文档?


页: [1]

雪羽2007-10-18 07:28
C#中如何打开带有密码的OFFice文档?

最近遇到一个比较广泛的问题,请教各位:

  我使用的VS2005,Frame 2.0版本,如何才能操作带有密码的Office文档?

现在的代码如下(Word):

第一次打开,并添加密码PasswordDocument,

[code]Word.Document wordDoc = m_WordApp.Documents.Add(ref Template, ref NewTemplate, ref DocumentType, ref Visible);[/code]

[code]wordDoc.SaveAs(ref filename, ref tempObject, ref tempObject, ref PasswordDocument, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject, ref tempObject);[/code]

第二次调用激活类ActivePaper(使用进程控制),弹出需要输入密码的对话框,我试过其他方法如自带的Open等都不能打开。

[code]ActivePaper(path, PaperType.Word);[/code]


雪羽2007-10-26 08:20
怎么没有人回啊?

没办法,只好换一种方法了,
使用嵌入方式,就无需考虑激活了

已ok


查看完整版本: C#中如何打开带有密码的OFFice文档?