您的位置:首页 > 其它

windows server 2008下无法用程序打开一个xls文件问题

2010-08-24 17:23 706 查看
今天,客户告诉我突然导入excel文件中的内容到文档中这个功能无法使用了,经仔细查看,后台报错如下:

Microsoft Office Excel: 不能取得类 Workbooks 的 Open 属性

下面是我的代码:

Set Exl=createObject("Excel.application")

Set Book=Exl.application.WorkBooks.open(path$)

Call CreateDoc(Book,db)

服务器现实环境变化:服务器操作系统由原来的windows server 2003 换成windows server 2008 64位。

分析:

服务器上已经安装了office2003,因为该功能是最近不正常的,之前的office版本也是2003,所以不会存在office版本的问题。

经测试,导出excel的功能正常,即Set excelWorkbook = excelApplication.Workbooks.Add Set excelSheet = excelWorkbook.Worksheets("Sheet1")这段代码运行正常,只是找不到Workbooks的open属性而已。

怀疑是权限问题,2008的server版本对权限控制加强,但却无从下手。

后来经不断查找资料,看到这样一份信息:

・Windows 2008 Server x64
Please make this folder.

C:\Windows\SysWOW64\config\systemprofile\Desktop

・Windows 2008 Server x86

Please make this folder.

C:\Windows\System32\config\systemprofile\Desktop

...instead of dcomcnfg.exe.

This operation took away office automation problems in my system.

A Desktop folder seems to be necessary in the systemprofile folder to open file by Excel.

It disappears from Windows2008, Windows2003 had the folder,
and I think it cause this error.

经过以上处理,问题虽然得带解决,但是为什么在 系统盘(C):\Windows\SysWOW64\config\systemprofile\目录下创建名为Desktop目录即可解决问题,仍然不是很清楚。继续查了一些资料,个人认为应该还是权限的问题,希望有高手能够为我解答下这个疑问。

虽然最终原理不是很清楚,但至少解决了问题,留下解决方法,希望对大家有点帮助。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐