以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  这是什么节凑,好几台电脑都出现这错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=69720)

--  作者:jaegea
--  发布时间:2015/6/9 20:05:00
--  这是什么节凑,好几台电脑都出现这错误
System.TypeInitializationException: The type initializer for \'UserCode\' threw an exception. ---> System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00853A19-BD51-419B-9269-2DABE57EB61F} failed due to the following error: 80040154.
--  作者:大红袍
--  发布时间:2015/6/9 20:12:00
--  

呃,你这个项目有考勤机的功能?

 

如果要弄了考勤机,对对应的dll文件要加上去,而且各台电脑都要安装一下才行。


--  作者:jaegea
--  发布时间:2015/6/10 11:05:00
--  

Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\123.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(0)
Ws.Protect(Password:="PReports") 
Wb.Save
App.Quit

出現下面錯誤

System.Runtime.InteropServices.COMException (0x8002000B): 无效索引。 (异常来自 HRESULT:0x8002000B (DISP_E_BADINDEX))
   在 Microsoft.Office.Interop.Excel.Sheets.get__Default(Object Index)
   在 UserCode.AJHw3INbZ509yzu7d(ControlEventArgs e)

這個呢?


--  作者:大红袍
--  发布时间:2015/6/10 11:14:00
--  

 Wb.WorkSheets(0)

 

 从1开始的,不是0

[此贴子已经被作者于2015/6/10 11:13:50编辑过]

--  作者:jaegea
--  发布时间:2015/6/10 12:31:00
--  
怎样对整个excel文件设置只读密码和读写密码?
--  作者:jaegea
--  发布时间:2015/6/10 12:50:00
--  

已经解决

Wb.Password = "123"     \'\'\'打开密码
Wb.WritePassword = "123"    \'\'\'写权限密码