Excel vba workbooks.open 事件给出运行时错误 1004 - 磁盘已满
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24867818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel vba workbooks.open event giving a runtime error 1004 - The Disk Is Full
提问by Carl
I'm getting a 1004 disk is full error when I try and open a file using:
当我尝试使用以下方法打开文件时,出现 1004 磁盘已满错误:
Workbooks.Open Filename:=inputfolder & "\" & inputfile, ReadOnly:=True
I have also tried this with the filepath and name hard-coded, with the same result. Does anyone have any ideas as to the cause?
我也尝试过使用硬编码的文件路径和名称,结果相同。有没有人对原因有任何想法?
回答by Bizmark
I've run into this error while trying to open from a shared location, it was caused by not having write permissions on the folder.
我在尝试从共享位置打开时遇到了这个错误,这是由于没有对该文件夹的写权限造成的。
If this is the case, try running the same code but with workbooks saved locally on your PC.
如果是这种情况,请尝试运行相同的代码,但使用 PC 本地保存的工作簿。
回答by Alexander Bell
First, try to check if it works with hard-coded full path to file, like (for example):
首先,尝试检查它是否适用于硬编码的文件完整路径,例如(例如):
Workbooks.Open Filename:="C:\somedir\somefile.xls", ReadOnly:=True
If it does, then check your variables to make sure they point to right location. If the error persists, try to open ANY Excel file in that particular folder (just for test purpose, put an empty File test.xls
). If it works on that test file, then your target file is either corrupted, or you do not have permissions to open it; in case it fails again, then you probably do not have permissions on that folder.
如果是,请检查您的变量以确保它们指向正确的位置。如果错误仍然存在,请尝试打开该特定文件夹中的任何 Excel 文件(仅用于测试目的,放置一个空的 File test.xls
)。如果它适用于该测试文件,那么您的目标文件要么已损坏,要么您没有打开它的权限;如果它再次失败,那么您可能没有该文件夹的权限。
Regards,
问候,
回答by JoeFox
I had the same error. In my case the problem was the file extension. I used ".xls" and not ".xlsx" maybe it is the same issue with your path.
我有同样的错误。就我而言,问题是文件扩展名。我使用了“.xls”而不是“.xlsx”,也许这与您的路径存在相同的问题。
回答by user8291487
I had the same problem in a shared location. Same times the issue is that the data-base file is corrupted by using one of de diferent version of the excel. To solve it, we had just opened the data-base file, recovering the source with the excel itself automaticly, and close it.
我在共享位置遇到了同样的问题。同时,问题是使用不同版本的 excel 之一损坏了数据库文件。为了解决这个问题,我们刚刚打开数据库文件,用excel本身自动恢复源,然后关闭它。