I'm trying to make a form to manage the formating of the excel by using c# to call macro automatically.
However, when I import the macro to the excel it gets error
Exception from HRESULT: 0x800A03EC
I'm using VS 2012 and Excel 2013
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Configuration;
using VBIDE = Microsoft.Vbe.Interop;
using System.Runtime.InteropServices;
private void button1_Click(object sender, EventArgs e)
{
try
{
Microsoft.Office.Interop.Excel.Application m_execl = new Microsoft.Office.Interop.Excel.Application();
Excel._Workbook oWB = (Excel._Workbook)(m_execl.Workbooks.Open(filePath + "myExcel.xlsx", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing));
m_execl.Visible = true;
Microsoft.Vbe.Interop.VBComponent xlMod;
xlMod = oWB.VBProject.VBComponents.Import(filePathMarco + "AutoFilter.bas");
trandRptWeeklyApp.Run("AutoFilter");
}
catch (Exception ex)
{
}
}