[英]Method 'Open' of object 'Workbooks' failed
here is a very small piece of code. 这是一小段代码。 I tested and worked for office 03, 07, 10 versions without a problem.
我测试并为Office 03、07、10版本工作,没有任何问题。 but on one machine running Win7 and Office 2007 fails always on this line:
但是在一台运行Win7和Office 2007的计算机上总是在以下行失败:
Set oWB = oExcel.Workbooks.Open("C:\myFile.xls")
Method 'Open' of object 'Workbooks' failed
对象“工作簿”的方法“打开”失败
what is the possible solution? 有什么可能的解决方案? PS file is not damaged.
PS文件未损坏。
Dim oExcel As Excel.Application
Dim oWB As Workbook
Dim oWS As Worksheet
Dim rRng As Excel.Range
Application.ScreenUpdating = False
Set oExcel = New Excel.Application
Set oWB = oExcel.Workbooks.Open("C:\myFile.xls")
Set oWS = oExcel.Worksheets(2)
Set rRng = oWS.Range("C01:C500")
oExcel.Visible = False
thanks everyone. 感谢大家。
I found the solution, Foxit reader add-in in word was causing the trouble. 我找到了解决方案,Foxit Reader插件出现了问题。 once removed everything worked.
一旦删除,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.