CShapes.AddPicture()函数导致的Excel进程无法自动关闭
张小毅oO 2017-08-23 10:42:37 在使用VS保存Excel的过程中用到了保存图片的功能,调用了AddPicture()函数之后Excel进程无法自行关闭,必须关掉程序,Excel进程才会随程序一起关闭。
代码中加入myExcelApp.put_Visible(TRUE);发现Excel的窗口和界面能够关闭的, 但是仍然会残留一个没有界面的Excel进程。目前只能使用ShellExecute强行关闭Excel进程。
NumChangeAA(indexX,indexY);//转换至Excel相应坐标
writeRange = startRange.get_Range(COleVariant(outChar),COleVariant(outChar));//outchar为得到的坐标
shaps = sheet.get_Shapes();
shaps.AddPicture(picPath,false,true,(float)writeRange.get_Left().dblVal,(float)writeRange.get_Top().dblVal,writeRange.get_Width().dblVal,writeRange.get_Height().dblVal);
writeRange.ReleaseDispatch();
shaps.ReleaseDispatch();
关闭和释放程序大同小异,不使用 shaps.AddPicture()是可以自行关闭进程的。
有没有办法让Excel自行关闭的方法,现在的情况就是有一个未知的 图形界面都已经关闭的 Excel进程,不知道哪里出问题了。