HRESULT: 0x800A03EC on Worksheet.range

前端 未结 23 2090
Happy的楠姐
Happy的楠姐 2020-11-22 07:42

I am getting HRESULT: 0x800A03EC on Worksheet.range method. Number of rows are more than 70K. Office 2007.

Code:

Microsoft.Office.Interop.Excel.Range         


        
相关标签:
23条回答
  • 2020-11-22 08:07

    I received this error code 0x800A03EC when trying to save an Excel file created within my .Net application in VS 2017. I changed the Excel.Application object property Visible=True and let it run until the point of failure. Tried to finish the steps manually in Excel and then discovered I could not save the file because of missing folder permissions. I added the Write permission to the folder, and the error went away.

    0 讨论(0)
  • 2020-11-22 08:07

    For others like me, who have the same exception:

    It can also happen if you try to pass a null value instead of Missing.Value (or Type.Missing)

    e.g.

    Worksheet worksheet = ...;
    return worksheet.Range["A1", null]; //This call generates the error 0x800A03EC
    
    return worksheet.Range["A1", Missing.Value]; //This works correctly
    
    0 讨论(0)
  • 2020-11-22 08:10

    This could also be caused if you have no room on the partition you are saving to.

    I checked my HD and foind it was maxed. Moving some un-needed files to a different partition resolved my problem.

    0 讨论(0)
  • 2020-11-22 08:10

    EDIT: THIS IS WAY BETTER!!! You don't need that old function, sorry. Just do as follows:

    Microsoft.Office.Interop.Excel.Range neededRange = currentWS.Range["A1", ((Microsoft.Office.Interop.Excel.Range)currentWS.Cells[nRowCount, nColumnCount])];
    

    That should work like a charm. And for future reference, put the relevant code that you are using inside of your question. Don't make people ask for it in comments. I imagine that's why you got downvoted.

    0 讨论(0)
  • 2020-11-22 08:11

    I encountered this issue.

    Discovered that somewhere in my code I was asking it to count starting from 0 (as you would in a C# code).

    Turns out Excel counting starts at 1.

    0 讨论(0)
  • 2020-11-22 08:11

    Looking at the various responses above, and drawing on my own recent experience (I got this error code doing something completely unrelated -- setting Application.Calculation) I conclude that the same error code is used to indicate multiple unrelated problems. So @Garreh you should probably be asking a new question (not that anyone will be able to help based on the error code alone). I've seen the same thing working with Word interop from C#, where the same HRESULT seems to be used for almost every kind of error. I've never found any satisfactory Microsoft documentation on what the codes might mean.

    0 讨论(0)
提交回复
热议问题