MFC API实现Excel读写 屏蔽调用SaveAs函数时弹出“文件已存在”问题

 

  CApplication ExcelApp;

  ExcelApp.put_DisplayAlerts(FALSE);
    book.SaveAs(_variant_t(strSaveAsName), _variant_t((long)56), vtMissing, vtMissing, vtMissing,
   vtMissing, 0,vtMissing , vtMissing, vtMissing,
   vtMissing,vtMissing);
  ExcelApp.put_DisplayAlerts(TRUE);

 

 解决方法:在调用SaveAs函数的前后加上如上两行代码

 

 

你可能感兴趣的:(VC++,MFC,编程小技巧)