@ravi kumar
Is the suffix of the current excel file "xls" or "xlsx"?
If it is the former, the "J1000000" in the code may be the reason,
The excel file in xls format has up to 65536 lines.
Exception from HRESULT: 0x800A03EC Error when using excel VSTO
ravi kumar
331
Reputation points
i am creating excel VSTO , Where i need to filter the column "J" in my excel sheet which are greater than 0 and delete those rows and remove the filter again.The below code was working fine during debugging and testing , but when i published the same and installed , it is throwing me the below error:
this is the code::
using Microsoft.Office.Tools.Ribbon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;
using Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
namespace CpCpk
{
public partial class Ribbon1
{
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
try
{
var excelappp = Globals.ThisAddIn.Application;
Excel.Worksheet Activeworksheet = Globals.ThisAddIn.Application.ActiveSheet;
Activeworksheet.Range["A:S"].AutoFilter(Field: 10, Criteria1: ">0");
excelappp.DisplayAlerts = false;
Activeworksheet.Range["J2:J1000000"].SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeVisible).Delete();
excelappp.DisplayAlerts = false;
Activeworksheet.ShowAllData();
}
catch (Exception ex)
{
MessageBox.Show("the error is:" + ex);
}
}
please help me how to solve this:
1 answer
Sort by: Most helpful
-
Timon Yang-MSFT 9,591 Reputation points
2021-01-19T05:33:07.837+00:00