简体   繁体   English

通过VBA打开Excel文件时出错

[英]Error when opening excel files through VBA

Have an excel file that imports other excel files, however when I open one of the files, it is corrupt and says... 有一个导入其他excel文件的excel文件,但是当我打开其中一个文件时,它已损坏并显示...

"We found a problem with some content... blah blah... recover as much as we can.. yes or no?" “我们发现了一些内容上的问题……等等……我们会尽可能地恢复。是或否?”

My code is the below and it currently opens the file and closes it, I think it is getting stuck at the error message. 我的代码如下,它当前打开文件并关闭它,我认为它被卡在错误消息中。 Any ideas? 有任何想法吗?

 Application.DisplayAlerts = False
 Application.EnableEvents = False
 Workbooks.Open (ARFile), UpdateLinks:=Yes
 Application.DisplayAlerts = True
 Application.EnableEvents = True

Edit - I condensed the code to just target the file and it opens the file then says "Method Open of Object Workbooks' Failed" and closes 编辑-我压缩了代码以仅将文件作为目标,然后打开文件,然后说“对象工作簿的方法打开失败”并关闭

Workbooks.Open ("C:\Users\bob\Desktop\Client\Project\D-F - All 
Reports_3018489300_030117_103117 .xlsx")

使用destroyload选项:

Workbooks.Open (ARFile), UpdateLinks:=Yes, corruptload:=xlRepairFile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM