HI,
I am trying to extract embedded objects from word document which is excel file.When i am trying to activate it, it throws error as command failed. For this i am getting porgramID as Excel.Sheet.8. Microsoft.Office.Interop.Excel.Application. I have office 365 installed on my machine.Here is the code snippet:
case "Excel.Sheet.12":
case "Excel.Sheet.8":
if (inlineShape.OLEFormat.DisplayAsIcon)
{
try { inlineShape.OLEFormat.Activate(); } catch (Exception ex) { Logger1.Log(ex.Message, ex.StackTrace); continue; }
string excelPath = string.Empty;
if (string.IsNullOrEmpty(inlineShape.OLEFormat.IconLabel))
excelPath = Path.Combine(attachmentSavePath, "MicrosoftExcel.xlsx");
else
excelPath = Path.Combine(attachmentSavePath, inlineShape.OLEFormat.IconLabel);
Microsoft.Office.Interop.Excel.Application excel;
excel = Marshal.GetActiveObject("Excel.Application") as Microsoft.Office.Interop.Excel.Application;
excel.Application.Visible = false;
excel.DisplayAlerts = false;
excel.ActiveWorkbook.SaveAs(excelPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, true, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
excel.ActiveWorkbook.Close();
excel.Application.Quit();
excel.Quit();
if (excel != null) Marshal.ReleaseComObject(excel);
}
break;
I am trying to extract embedded objects from word document which is excel file.When i am trying to activate it, it throws error as command failed. For this i am getting porgramID as Excel.Sheet.8. Microsoft.Office.Interop.Excel.Application. I have office 365 installed on my machine.Here is the code snippet:
case "Excel.Sheet.12":
case "Excel.Sheet.8":
if (inlineShape.OLEFormat.DisplayAsIcon)
{
try { inlineShape.OLEFormat.Activate(); } catch (Exception ex) { Logger1.Log(ex.Message, ex.StackTrace); continue; }
string excelPath = string.Empty;
if (string.IsNullOrEmpty(inlineShape.OLEFormat.IconLabel))
excelPath = Path.Combine(attachmentSavePath, "MicrosoftExcel.xlsx");
else
excelPath = Path.Combine(attachmentSavePath, inlineShape.OLEFormat.IconLabel);
Microsoft.Office.Interop.Excel.Application excel;
excel = Marshal.GetActiveObject("Excel.Application") as Microsoft.Office.Interop.Excel.Application;
excel.Application.Visible = false;
excel.DisplayAlerts = false;
excel.ActiveWorkbook.SaveAs(excelPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, true, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
excel.ActiveWorkbook.Close();
excel.Application.Quit();
excel.Quit();
if (excel != null) Marshal.ReleaseComObject(excel);
}
break;