Save as docx from Word 2007

D

David

I'm attempting to open a .doc file in a C++ Word 2007 automation
program and save it as docx, but the resulting document is always in
compatibility mode. Here's the relevant code:

short wdFormatXMLDocument = 12;
COleVariant vXMLFormat(wdFormatXMLDocument, VT_I2);
CString sName = m_pDocument->get_FullName();
CString sTempName = sName + _T("x");
CComVariant vName(sName);
CComVariant vTempName(sTempName);
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
m_pDocument->SaveAs(&vTempName, &vXMLFormat, &covOptional,
&covOptional, &covOptional, &covOptional, &covOptional, &covOptional,
&covOptional, &covOptional, &covOptional, &covOptional, &covOptional,
&covOptional, &covOptional, &covOptional);
m_pDocument->Close(&viDoNotSave, &vOriginalFormat, &vbFalse);
m_pDocument = NULL;
closeDoc(false);

Instead of wdFormatXMLDocument I've also tried long
wdFormatDocumentDefault = 16, with the same result.

Can anyone tell me what I'm doing wrong?

Thanks,
David
 
D

David

For anyone who may be reading this and having the same problem, the
solution is to call the Convert() method of the document class before
calling SaveAs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top