怎样用VC把BMP图片保存在word文档中?有例子最好 怎样用VC把BMP图片保存在word文档中?有例子最好 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 vckbase里面有把文字保存到word文档中的例子 http://www.vckbase.com/document/viewdoc/?id=1174 通过_Application, _Document取到inlineshapes调用inlineshapes.AddPicture() // ok... // Office !! Word !!! _Application app; app.CreateDispatch(_T("Word.Application")); Documents docs = app.GetDocuments(); CComVariant Template(_T("")), NewTemplate(false), DocumentType(0), Visible;// app.SetVisible(TRUE); docs.Add(&Template, &NewTemplate, &DocumentType, &Visible); Selection sel = app.GetSelection(); _Document doc = app.GetActiveDocument(); sel.TypeText(_T("HELLO\r\nHello World!!")); sel.TypeParagraph(); // add picture. CComVariant picLinkToFile(false), SaveWithDocument(true); CComVariant picRange(sel.GetRange());// picRange.vt = VT_DISPATCH;// picRange.pdispVal = sel.GetRange(); InlineShapes picInShapes = sel.GetInlineShapes(); picInShapes.AddPicture(m_strImageName, &picLinkToFile, &SaveWithDocument, &picRange); // save as. CComVariant FileName(m_strPathName); CComVariant FileFormat(0); CComVariant LockComments(false), Password(_T("")); CComVariant AddToRecentFiles(true), WritePassword(_T("")); CComVariant ReadOnlyRecommended(false), EmbedTrueTypeFonts(false); CComVariant SaveNativePictureFormat(false), SaveFormsData(false); CComVariant SaveAsAOCELetter(false); CComVariant Encoding, InsertLineBreaks, AllowSubstitutions, LineEnding, AddBiDiMarks; doc.SaveAs(&FileName,&FileFormat,&LockComments,&Password, &AddToRecentFiles,&WritePassword,&ReadOnlyRecommended, &EmbedTrueTypeFonts,&SaveNativePictureFormat,&SaveFormsData, &SaveAsAOCELetter); // release and quit. doc.ReleaseDispatch(); sel.ReleaseDispatch(); docs.ReleaseDispatch(); CComVariant SaveChanges(false), OriginalFormat, RouteDocument; app.Quit(&SaveChanges, &OriginalFormat, &RouteDocument); app.ReleaseDispatch(); CTreeCtrl的子项尺寸如何改变? 如何响应属性表单应用按钮点击的命令 网页游戏外挂? 在MFC中通过MCIWndCreate实现播放视频 对话框中使用CRichEditCtrl,如何突破64k字符的限制? 减少FLOAT精度 如何在自定义结构中表示位? 如何通过UDP获知局域网中有哪些UDP服务器? 直线 保存 有人能想通这是怎么算出来的吗? CListCtrl类的行高度可不可以加大? 系统未安装打印机,如何实现打印预览
调用inlineshapes.AddPicture()
// Office !! Word !!!
_Application app;
app.CreateDispatch(_T("Word.Application")); Documents docs = app.GetDocuments();
CComVariant Template(_T("")), NewTemplate(false), DocumentType(0), Visible;
// app.SetVisible(TRUE);
docs.Add(&Template, &NewTemplate, &DocumentType, &Visible); Selection sel = app.GetSelection();
_Document doc = app.GetActiveDocument();
sel.TypeText(_T("HELLO\r\nHello World!!"));
sel.TypeParagraph(); // add picture.
CComVariant picLinkToFile(false), SaveWithDocument(true);
CComVariant picRange(sel.GetRange());
// picRange.vt = VT_DISPATCH;
// picRange.pdispVal = sel.GetRange();
InlineShapes picInShapes = sel.GetInlineShapes();
picInShapes.AddPicture(m_strImageName, &picLinkToFile, &SaveWithDocument, &picRange); // save as.
CComVariant FileName(m_strPathName);
CComVariant FileFormat(0);
CComVariant LockComments(false), Password(_T(""));
CComVariant AddToRecentFiles(true), WritePassword(_T(""));
CComVariant ReadOnlyRecommended(false), EmbedTrueTypeFonts(false);
CComVariant SaveNativePictureFormat(false), SaveFormsData(false);
CComVariant SaveAsAOCELetter(false);
CComVariant Encoding, InsertLineBreaks, AllowSubstitutions, LineEnding, AddBiDiMarks; doc.SaveAs(&FileName,&FileFormat,&LockComments,&Password,
&AddToRecentFiles,&WritePassword,&ReadOnlyRecommended,
&EmbedTrueTypeFonts,&SaveNativePictureFormat,&SaveFormsData, &SaveAsAOCELetter);
// release and quit.
doc.ReleaseDispatch();
sel.ReleaseDispatch();
docs.ReleaseDispatch();
CComVariant SaveChanges(false), OriginalFormat, RouteDocument;
app.Quit(&SaveChanges, &OriginalFormat, &RouteDocument);
app.ReleaseDispatch();