咨询ole专家们:GetActiveObject EOleSysError---->Operationin unvaliable
try // checks if Excel is opened
{
xl_app = Variant::GetActiveObject("Excel.Application");
}
catch(EOleSysError& error1) // Excel is not opened, open it.
//catch(...)
{
xl_app = Variant::CreateObject("Excel.Application"); //open excel
}
抛出“不可用的操作”异常,catch 捕获不到,请教诸位这个问题的解决方法。 Excel OLE
[解决办法]
#include <comobj.hpp>
Variant xl_app;
try // checks if Excel is opened
{
xl_app = GetActiveOleObject("Excel.Application");
}
catch (...)
{
xl_app = CreateOleObject("Excel.Application"); //open excel
}