在VC中向word中插入图片,提示“类型不匹配”
if (::CoInitialize(NULL) != 0)
{
AfxMessageBox("初始化COM失败");
return;
}
_Application app;
app.CreateDispatch(_T("Word.Application"));
app.SetVisible(TRUE);
Documents docs = app.GetDocuments();
CComVariant Template(_T("")); //不使用模板
CComVariant NewTemplate(false), DocumentType(0),Visible;
docs.Add(&Template,&NewTemplate,&DocumentType,&Visible);
Selection sel=app.GetSelection();
//调用函数Selection::TypeText 向WORD发送字符
sel.TypeText(_T("HELLO\r\n大家好呀"));
Range selRange = sel.GetRange();
InlineShapes inlineShapes = sel.GetInlineShapes();
CComVariant linktoFile(false),SaveWithDocument(false),range;
inlineShapes.AddPicture(_T("F:\\13.jpg"),&linktoFile,&SaveWithDocument,&range);
相关推荐
使用VC向WORD中插入图片
简单的例子,可以在VC中向WORD插入图片。
vc操作word在指定位置插入图片
在指定的位置插入图片,,vc word 指定位置插入图片
怎么利用vc在打开的word文件的光标位置插入图片.doc
void CBbView::OnPicture() { CString filename; CString defaultfilename=""; CString filepath; CString fileextention;//文件扩展名 CString filter;//文件过滤 filter="位图文件(*.bmp)|*.bmp|JPG文件(*.jpg)|*.jpg|所有文件(*.*)|*.*||"; fileextention=".bmp"; CFileDialog OpenDlg1(TRUE,fileextention,defaultfilename, OFN_HIDEREADONLY,filter);//true 为打开,false 为保存 if(OpenDlg1.DoModal () == IDCANCEL)
MFC在word模板中插入文字和图片生成文档实例
winxp vc6.0 office2003开发环境下,MFC编程实现在word模板中插入文字和图片生成文档。
VC操作word:VC中将BMP位图输出到Word中(非常实用)-源代码是MFC框架
本程序是基于MFC多文档框架的,实现了实时将需要路径的位图文件插入到指定的word文档中,实现了VC直接操作word方法,非常实用。


