Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Have an excel file that imports other excel files, however when I open one of the files, it is corrupt and says...

"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:UsersobDesktopClientProjectD-F - All 
Reports_3018489300_030117_103117 .xlsx")
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
164 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use the corruptload option:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...