我正在使用saveAs2方法将word文档保存为XML格式文档。 我的应用程序执行得非常好,直到我的系统中有MS Office 2010。 但是,一旦我将系统升级到office365(MSoffice2013版本),应用程序在执行saveAs2时就开始抛出异常。
解决此问题的任何线索,请发布。
代码段:
int CWordDoc::SaveAs(CString filename, short file_format)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString new_filename;
if(filename.GetLength() == 0)
{
new_filename = filename;
}
// COleVariant var_filename((_bstr_t) filename);
COleVariant var_filename(filename);
COleVariant var_fileformat(file_format);
short file_formatCompat = 14;
COleVariant var_fileformatCompat(file_formatCompat);
#if MSWORD8
wordDoc.SaveAs(&var_bstr,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing);
#elif MSWORD11
wordDoc.SaveAs2(&var_filename,
&var_fileformat,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&vtMissing,
&var_fileformatCompat);
#else
#pragma message("Unknown MSWord version (must define MSWORD8 or MSWORD11)")
#endif
return 1;
}
获得以下例外:
.exe中的未处理异常(KERNELBASE.DLL)0XE06D7363:Microsoft C ++异常“