利用wxWidgets打开、保存word文档

wxAutomationObject wordObject, documentObject;

if ( wordObject.CreateInstance ( _T("Word.Application") ) )
{
    wxVariant openParams[2];
    openParams[0] = rtfFile;
    openParams[1] = false;

    wordObject.CallMethod(_("documents.open"), 2, openParams);
    if (!wordObject.GetObject(documentObject, _("ActiveDocument")))
    {
        return;
    }
    wxVariant saveAsParams[2];
    saveAsParams[0] = docFile;
    saveAsParams[1] = (long)0; //wdFormatDocument
    if ( !documentObject.CallMethod(_("SaveAs"), 2, saveAsParams) )
    {
        return;
    }
    documentObject.CallMethod(_("Close"), 0, NULL );
    wordObject.CallMethod(_T("Quit"), 0, NULL );
}

 

你可能感兴趣的:(wxwidgets)