求VC2005 MFC 用窗体 (而不是单 多文档结构)内嵌打开WORD 操作 在网上有 单文档 做的,我想转到窗体中,但出错了。不知谁有 VC2005 MFC 用窗体 (而不是单 多文档结构)内嵌打开WORD 操作
的源代码,(注意是用窗体内嵌打开WORD)
void CWord::OnBnClickedButton1()
{
vWord = (CofficeView*)GreateView(); 
 vWord->MoveWindow(1,1,1111,881); 
 //vWord->EmbedAutomateWord();
}
CView* CWord::GreateView()
{
CCreateContext Content;     Content.m_pCurrentFrame = (CFrameWnd*)this;     Content.m_pNewDocTemplate = NULL;     Content.m_pCurrentDoc = NULL;     Content.m_pLastView = NULL; 
CView* pTemp ; Content.m_pNewViewClass = RUNTIME_CLASS(CofficeView); 
 pTemp = (CView*)Content.m_pNewViewClass->CreateObject(); 
pTemp->Create(NULL,NULL  ,AFX_WS_DEFAULT_VIEW,CRect(0,0,0,0),this,AFX_IDW_PANE_FIRST,&Content); //这里出错
return  (CofficeView*)pTemp; 
}
void CWord::OnBnClickedButton1()
{
vWord = (CofficeView*)GreateView(); 
 vWord->MoveWindow(1,1,1111,881); 
 //vWord->EmbedAutomateWord();
}
CView* CWord::GreateView()
{
CCreateContext Content;     Content.m_pCurrentFrame = (CFrameWnd*)this;     Content.m_pNewDocTemplate = NULL;     Content.m_pCurrentDoc = NULL;     Content.m_pLastView = NULL; 
CView* pTemp ; Content.m_pNewViewClass = RUNTIME_CLASS(CofficeView); 
 pTemp = (CView*)Content.m_pNewViewClass->CreateObject(); 
pTemp->Create(NULL,NULL  ,AFX_WS_DEFAULT_VIEW,CRect(0,0,0,0),this,AFX_IDW_PANE_FIRST,&Content); 
return  (CofficeView*)pTemp; 
}

解决方案 »

  1.   

    单多文档中采用view frame等
    窗体就是Dialog,直接在Dialog中操作word
      

  2.   

    直接在Dialog中操作word ,我的程序是 基于 Dialog的,另外 Dialog好美化界面,我想把把和窗体有关的去掉可出错呀,
    有没有人帮忙
      

  3.   

    我把代码放到了 http://www.gxfc.org/office.rar 请高手指点 万分感谢
      

  4.   

    Read Document Text Directly from Microsoft Word File
    http://www.codeproject.com/KB/cs/getwordtext.aspx是基于对话框的,不过是 C# ...
      

  5.   

    好了,帮你找到了终极解决方案
    A Rich Edit Control That Displays Bitmaps and Other OLE Objectshttp://www.codeproject.com/KB/edit/COleRichEditCtrl.aspxCOleRichEditCtrl will display RTF text as well as bitmaps, video clips, Word, Excel and PowerPoint documents, and any other kind of OLE objects. 

      

  6.   

    感谢DavidHsing ,一定给你分,谢谢 ,但我不要C# 的, 第二个的也看了,操作不了WORD 我要能操作WORD才行呀。谢谢。
      

  7.   

    COleRichEditCtrl will display RTF text as well as bitmaps, video clips, Word, Excel and PowerPoint documents, and any other kind of OLE objects. 你看一下代码,按说明是可以读取 Word 的。
    只不过函数里面只写了从资源中读取文件流来显示的代码。
    从文件读取的话,需要你自己扩充。
      

  8.   

    谢谢,是可以读,但根据标签替换,或其实WORD功能可能不能使用。呵,
      

  9.   

    TO : jameshooo 
    我把源码放到
    http://www.gxfc.org/office.rar 请高手指点 万分感谢
    你一定能解决,我想具体问一下,就是让我能用这个 窗体上的VIEW 打开WORD 操作就行void CWord::OnBnClickedButton1() 

    vWord = (CofficeView*)GreateView(); //这里出错 
    vWord->MoveWindow(1,1,1111,881); 
    vWord->EmbedAutomateWord(); //请问在这里新创个view打开wordR操作怎么写呢

    CView* CWord::GreateView() 

    CCreateContext Content; 
        Content.m_pCurrentFrame = (CFrameWnd*)this; 
        Content.m_pNewDocTemplate = NULL; 
        Content.m_pCurrentDoc = NULL; 
        Content.m_pLastView = NULL; 
    CView* pTemp ; 
    Content.m_pNewViewClass = RUNTIME_CLASS(CofficeView); 
    pTemp = (CView*)Content.m_pNewViewClass->CreateObject(); 
    pTemp->Create(NULL,NULL  ,AFX_WS_DEFAULT_VIEW,CRect(0,0,0,0),this,AFX_IDW_PANE_FIRST,&Content); //这里出错 
    return  (CofficeView*)pTemp; 
      

  10.   

    你这里是创建view出错CView* pTemp = new CView; 
      

  11.   

    你分析一下你的COfficeView,看能不能将它改成从CWnd类派生的而不是从CView类派生的类