word对象生成的二进制流(IStorage)怎么反向生成 word文档??

解决方案 »

  1.   

    LPDISPATCH lpDisp;
    lpDisp=m_pWebOfficeFrame->m_pWebOfficeView->m_pSelection->GetIDispatch();
    TCHAR szTempPath[MAX_PATH],szTempFile[MAX_PATH];
        DWORD dwResult=::GetTempPath(MAX_PATH,szTempPath);
    GetTempFileName(szTempPath,_T("TelStar_"),0,szTempFile);
    CString strTempDocPath;
    strTempDocPath=szTempFile;

    USES_CONVERSION;
    WCHAR* wcPathName=T2W(szTempFile);
    IStorage* pStorage=NULL;
    BOOL bSuccess=FALSE;
    if(SUCCEEDED(StgCreateDocfile(wcPathName,STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE,0,&pStorage)))
    {
    IPersistStorage* pPersistStorage=NULL;
    if(SUCCEEDED(lpDisp->QueryInterface(IID_IPersistStorage,(void**)&pPersistStorage)))
    {
    if(SUCCEEDED(OleSave(pPersistStorage,pStorage,FALSE)))
    {
    pPersistStorage->SaveCompleted(NULL);
    }
    pPersistStorage->Release();
    }
    pStorage->Release();
    }
    szTempFile文件就是Word文件