求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;
}
的源代码,(注意是用窗体内嵌打开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;
}
窗体就是Dialog,直接在Dialog中操作word
有没有人帮忙
http://www.codeproject.com/KB/cs/getwordtext.aspx是基于对话框的,不过是 C# ...
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.
只不过函数里面只写了从资源中读取文件流来显示的代码。
从文件读取的话,需要你自己扩充。
我把源码放到
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;
}