MFC 创建excel时候报错,求解答

问题描述:

//删除表 只剩下一个表
for (short i = 1; i<= (short)m_wsExcels.get_Count(); i++)
{
    m_wsExcelSingle.AttachDispatch(m_wsExcels.get_Item(COleVariant((short)i)));
    m_wsExcelSingle.Delete();
}

运行到这里的时候报错,是什么原因呢

CATCH_ALL(e)
{
lResult = AfxProcessWndProcException(e, &pThreadState->m_lastSentMsg);
TRACE(traceAppMsg, 0, "Warning: Uncaught exception in WindowProc (returning %ld).\n",
lResult);
DELETE_EXCEPTION(e);
}