权限被拒绝使用Excel 12.0 Library& VB6 [英] Permission Denied opening an Excel File using Excel 12.0 Library & VB6
问题描述
我正在尝试打开一个excel(xls或xlsx)文件并读取值,你可能会看到。
当我尝试打开文件时,我收到错误70权限被拒绝)错误。奇怪的是,没有其他的excel开放实例(在任务管理器应用程序或进程中)。没有人试图访问该文件。我可以在没有警告的情况下打开excel文件,我也可以使用基本的Open File for Input as#1语法来打开/读取/关闭VB6中的文件,没有错误。我可以使用Kill()删除该文件,因此它不能是目录权限问题 - 请帮助 - 我失去了!!!
Dim xlApp As New Excel.Application
Dim xlWBook As Excel.Workbook
'错误发生在这里
设置xlWBook = xlApp.Workbooks.Open (文件)
Dim xlSheet作为Excel.Worksheet
设置xlSheet = xlWBook.Sheets.Item(1)
Dim y As Integer
对于y = 1 To 99999
如果Len(xlSheet.Cells(y,1))> 0然后
发送xlSheet.Cells(y,1)& - & xlSheet.Cells(y,2)& <峰; br> 中
结束如果
下一个
设置xlWBook =没有
设置xlApp =没有
-Jay
Dim xlApp As New Excel.Application
Dim xlWBook As Excel.Workbook
'出现错误
设置xlWBook = xlApp.Workbooks.Open(文件)
没有定义哪个文件是。即。
File =C:\myDocuments\myexcel.xlsx。 '因为文件字符串是空的。
I have used Excel in my VB6 apps many times before, and have never run into such a weird problem trying to accomplish something very easy..
I am trying to open an excel (xls or xlsx) file and read through values, as you can probably see.
When I try to open the file, I get an error 70 (permission denied) error. The odd thing is that there is no other instance of excel open (in task manager apps or processes). No one else is trying to access the file whatsoever. I can open the file in excel with no warning, and I can also open/read/close the file in VB6 with the basic "Open File for Input as #1" syntax without error. I can delete the file using Kill() so it can't be a directory permissions issue - Please help - I am at a loss!!!
Dim xlApp As New Excel.Application
Dim xlWBook As Excel.Workbook
'Error Occurs Here
Set xlWBook = xlApp.Workbooks.Open(File)
Dim xlSheet As Excel.Worksheet
Set xlSheet = xlWBook.Sheets.Item(1)
Dim y As Integer
For y = 1 To 99999
If Len(xlSheet.Cells(y, 1)) > 0 Then
Send xlSheet.Cells(y, 1) & " - " & xlSheet.Cells(y, 2) & "<br>"
End If
Next
Set xlWBook = Nothing
Set xlApp = Nothing
-Jay
Dim xlApp As New Excel.Application
Dim xlWBook As Excel.Workbook
'Error Occurs Here
Set xlWBook = xlApp.Workbooks.Open(File)
There is no defined which File is. ie.
File="C:\myDocuments\myexcel.xlsx". 'Because File string is empty.
这篇关于权限被拒绝使用Excel 12.0 Library& VB6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!