Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed

Workbooks.Open with CorruptLoad parameter set to xlRepairFile fails on Excel
5.0/95 file due to Chart, with Error 1004 Method 'Open' of object
'Workbooks' failed.

We have a sample Excel 5.0 (Excel 95) file that is being opened through a
Visual Basic 6.0 function on Excel 2003 COM call. The Workbooks.Open method
succeededs if CorruptLoad is set to xlNormalLoad, but it fails with Error
1004 if Corrupt Load is set to xlRepairFile.

The Excel 5.0 document has a single sheet with a Chart on it. If the file
is modified such that only the chart is removed, the Open with xlRepairFile
works. If everything else is removed from the file and the Chart remains,
the xlRepairFile Open still fails.

Any ideas on why this might be failing? Is there a limitation of Excel 2003
opening Excel 5.0 file with Charts?
Thanks for any input on this topic.







Function WorkbooksFailSafeOpen(oWorkbooks As Workbooks, strLocalInputFile As
String) As Workbook

Dim lngErrNumber As Long
Dim strErrorDescription As String

On Error Resume Next

Set WorkbooksFailSafeOpen = oWorkbooks.Open(strLocalInputFile, _
UpdateLinks:=2, _
ReadOnly:=True, _
Password:="", _
IgnoreReadOnlyRecommended:=True, _
CorruptLoad:=xlRepairFile)

lngErrNumber = Err.Number

On Error GoTo 0

' If the first open failed with Error 1004
' Method 'Open' of object Workbooks' failed
' Try the alternate Open, without xlRepairFile setting

' Note we can't seem to get the description
' "Method 'Open' of object 'Workbooks' failed"
' out of the Err.Description variable, comes out as
' "Application-defined or object-defined error"
' even though pop-up dialog displays Method 'Open'... message
' so just check against generic error number 1004

If lngErrNumber = 1004 Then
Set WorkbooksFailSafeOpen = oWorkbooks.Open(strLocalInputFile, _
UpdateLinks:=2, _
ReadOnly:=True, _
Password:="", _
IgnoreReadOnlyRecommended:=True, _
CorruptLoad:=xlNormalLoad)
End If

End Function



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed

Hi Frank,

I can not reproduce the problem on my side, can you send me a reproduce
sample with the excel 5.0(Excel 95) sample file for me to reproduce the
problem.
You may reach me by removing "online" from my Email address.
So that we can do the further troubleshooting.

Thank you for you understanding.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed

Hi Frank,

I am sorry for delay response.

It seems that we can also reproduce the problem by manually opening the
file on Excel 2003
1) Start Excel 2003.
2) Click File, Open and browse to the "ExcelOpen-xlRepairFileFailure.xls"
file.
3) Click the Open dropdown button and select "Open and RepairĄ*"
4) Select the Repair option.
Result:

"Errors were detected in 'ExcelOpen-xlRepairFileFailure.xls', but Microsoft
Office Excel was able to open the file by making the repairs below..
Excel then reports:
"Damage to the file was so extensive that repairs were *not* possible.
Excel attempted to recover your formulas and values, but some data may have
been lost or corrupted."

Since the workbook cannot be repaired by Excel, you will get the run-time
error when you pass in the repair option to the Open method. This allows a
developer that is automating Excel to detect (by trapping the error) when a
workbook is corrupt and cannot be automatically repaired by Excel. By
Excel raising the error, the developer is allowed to trap for the error and
alert the user that this xls file is damaged and cannot be recovered. If
Excel did not raise an error in this case, the developer would not have
confidence that the workbook was opened/repaired successfully.

Did the problem persists with all your Excel 95 file with chart?

I have made a test that I was able to successfully repair a simple xl95
workbook with a chart. So I think there is something more specific to your
workbook that is causing the error.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
CorruptLoad param of Workbooks.Open Microsoft Excel Programming 6 April 17th 04 10:50 PM
Open method of workbooks fails when Excel is hosted in IE [email protected] Excel Programming 5 January 30th 04 02:19 AM
Open Method of workbooks class failed kiran[_2_] Excel Programming 0 November 6th 03 09:58 PM
Error 1004: Method 'Cells' of object '_Global' failed LT Excel Programming 2 October 31st 03 04:47 PM


All times are GMT +1. The time now is 09:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"