如何使用 MFC 创建并显示一个 PowerPoint 演示文稿

MFC开发wps演示 1、项目->add->class->MFC->MFC Class From Typelib->add 2、在Available type libraries中选择正确的库并添加要用到的类 3、在新加的类头文件中把#import "C:\\Users\\seer016\\AppData\\Local\\Kingsoft\\WPS Office\\10.1.0.6260\\office6\\wp 阅读详情
  1. 请按照下面的 Microsoft 知识库文章,以创建示例项目使用该 IDispatch 接口,并在 Msppt8.olb 类型库中的成员函数定义中的步骤 1 到 12:

    178749  (http://support.microsoft.com/kb/178749/EN-US/ ) 如何创建自动化项目使用 MFC 和类型库
  2. 请按 CTRL + W 以再次显示此类向导并选择自动选项卡,单击添加类按钮并选择一个类型库。找到 Graph8.olb,然后单击打开。选择"表"类别,然后单击确定。单击确定以关闭此类向导。

    注: 与本示例将创建的演示文稿包含嵌入的 Microsoft Graph 图表 ; 这是原因的在图中添加从 Microsoft Graph 类型库 (Graph8.olb) 的类。
  3. AutoProjectDlg.cpp 文件顶部添加以下行:
          #include "msppt8.h"
          #include "graph8.h"
    					
  4. 将下面的代码添加到 CAutoProjectDlg::OnRun() AutoProjectDlg.cpp 文件中:
       // Commonly used OLE-variants.
       COleVariant
                   covTrue((short)TRUE),
                   covFalse((short)FALSE),
                   covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
    
       _Application   app;
       Presentations  presentations;
       _Presentation  presentation;
       Slides         slides;
       _Slide         slide;
       ShapeRange     shaperange;
       Shapes         shapes;
       Shape          shape;
       TextFrame      textframe;
    
       TextRange      textrange;
       Font           font;
       FillFormat     fillformat;
       ColorFormat    colorformat;
       ShadowFormat   shadow;
    
          CString strPic1 ="C://Program Files//Microsoft Office//Clipart//Popular//Amhappy.wmf";
          CString strTemplate = 
             "C://Program Files//Microsoft Office//Templates//Presentation Designs//Zesty.pot";
    
    
        if(!app.CreateDispatch("Powerpoint.Application"))
          {
             AfxMessageBox("Could not create Powerpoint object.");
             return;
          }
    
          //Make the application visible and minimized.
          app.SetVisible((long)TRUE);
          app.SetWindowState((long) 2);   //ppWindowMinimized=2
    
          //Get the Presentations collection and create a new presentation
          //from a template(.POT)
          presentations.AttachDispatch(app.GetPresentations());
          presentation = presentations.Open(
             strTemplate,   //File name
             (long)0,       //Read-only
             (long)-1,      //Untitled
             (long)-1       //WithWindow
             );
    
          slides = presentation.GetSlides();
    
          //Add the first slide to the presentation.
          slide = (slides.Add((long)1, (long)11));   //pptLayoutTitleOnly=11
    
          //Modify the text and font name of the TextFrame on the slide.
          shapes = slide.GetShapes();
          shape = shapes.Item(COleVariant((short)1));
          textframe = shape.GetTextFrame();
          textrange = textframe.GetTextRange();
          textrange.SetText("My Sample Presentation");//Set the text
          font = textrange.GetFont();
          font.SetName("Comic Sans MS");              //Set the font name.
          font.SetSize((float)48);                    //Set the font size.
    
          //Insert a picture into the slide and position it.
    
          shapes.AddPicture(
                       strPic1,      //Filename
                       (long)0,      //LinkToFile
                       (long)-1,     //SaveWithDocument
                       (float)150,   //Left
                       (float)150,   //Top
                       (float)500,   //Width
                       (float)350    //Height
                       );
    
          //Add the second slide to the presentation.
          slide = (slides.Add((long)2, (long)11));   //pptLayoutTitleOnly=11
    
          //Modify the text and font name of the
          //TextFrame on the slide.
          shapes = slide.GetShapes();
          shape = shapes.Item(COleVariant((short)1));
          textframe = shape.GetTextFrame();
          textrange = textframe.GetTextRange();
          textrange.SetText("Look! It's a Graph!");//Set the text
          font = textrange.GetFont();
          font.SetName("Comic Sans MS");           //Set the font name.
          font.SetSize((float)48);                 //Set the font size.
    
          //Add a Graph8 object to the slide.
          shape = shapes.AddOLEObject(
                         (float)150,      //Left
                         (float)150,      //Top
                         (float)480,      //Width
                         (float)320,      //Height
                         "MSGraph.Chart", //Classname
                         "",              //FileName
                         (long)0,         //DisplayAsIcon
                         "",              //IconFileName
                         (long)0,         //IconIndex
                         "",              //IconLabel
                         (long)0          //Link
                         );
    
          //Modify the charttype of the graph.
          Chart chart;
          OLEFormat olefmt = shape.GetOLEFormat();
          chart = olefmt.GetObject();
          chart.SetChartType((long)70);
    
          //Add the third slide to the presentation.
          slide = (slides.Add((long)3, (long)12));   //ppLayoutBlank = 12
    
          //Change the background color of the slide.
          slide.SetFollowMasterBackground((long)0);
          shaperange = slide.GetBackground();
          fillformat = shaperange.GetFill();
          colorformat = fillformat.GetForeColor();
          colorformat.SetSchemeColor((long)3);   //ppShadow = 3
    
    
          //Add Text Effects to the last slide
          shapes = slide.GetShapes();
          shape = shapes.AddTextEffect(
                         (long)27,    //PresetTextEffect (msoTextEffect28 = 27)
                         "The End",   //Text
                         "Impact",    //FontName
                         (float)96,   //FontSize
    
                         (long)0,     //FontBold
                         (long)0,     //FontItalic
                         (float)230,  //Left
                         (float)200   //Top
                         );
    
          //Apply a gradient fill to the texteffect.
          fillformat = shape.GetFill();
          colorformat = fillformat.GetForeColor();
          colorformat.SetSchemeColor((long)2);   //ppForeground = 2
          colorformat = fillformat.GetBackColor();
          colorformat.SetSchemeColor((long)4);   //ppTitle = 4
    
          fillformat.TwoColorGradient ((long)1, (long)1);
                                                 //msoGradientHorizontal = 1
    
    
          //Apply a shadow to the texteffect.
          shadow = shape.GetShadow();
          colorformat = shadow.GetForeColor();
          colorformat.SetSchemeColor((long)2);   //ppForeground = 2
          shadow.SetVisible((long)-1);
          shadow.IncrementOffsetX((float)3);
          shadow.IncrementOffsetY((float)3);
    
          SlideShowTransition   show;
          SlideShowSettings   slideshow;
    
          //Set the Transition effects for Slide 1.
          slide = slides.Item(COleVariant((short)1));
          show = slide.GetSlideShowTransition();
          show.SetEntryEffect((long)769);      //ppEffectBlindsHorizontal=769
          show.SetAdvanceOnTime((long)-1);
          show.SetAdvanceTime((float)3);
    
          //Set the Transition effects for Slide 2.
          slide = slides.Item(COleVariant((short)2));
          show = slide.GetSlideShowTransition();
          show.SetEntryEffect((long)770);      //ppEffectBlindsVertical=770
          show.SetAdvanceOnTime((long)-1);
          show.SetAdvanceTime((float)3);
    
          //Set the Transition effects for Slide 3.
          slide = slides.Item(COleVariant((short)3));
          show = slide.GetSlideShowTransition();
          show.SetEntryEffect((long)3073);      //ppEffectBoxOut=3073
          show.SetAdvanceOnTime((long)-1);
          show.SetAdvanceTime((float)3);
    
          //Run the show.
          slideshow = presentation.GetSlideShowSettings();
          slideshow.Run();
    
          //Quit the application after waiting 9 seconds (the length of the
          //slide show).
          ::Sleep(9000);
          presentation.SetSaved((long)-1);
          app.Quit();
    					
  5. 如果需要修改该工作分配的 strPic1 和 strTemplate 到图像文件和一个 PowerPoint 演示文稿模板的有效路径:
    CString strPic1 ="C://Program Files//Microsoft Office//Clipart//Popular//Amhappy.wmf";
    CString strTemplate = 
             "C://Program Files//Microsoft Office//Templates//Presentation Designs//Zesty.pot";
    
MFC通过COM组件打开PPT,支持Office及WPS,包含测试代码、动态库及源码.7z MFC通过COM组件打开PPT,支持Office及WPS,包含测试代码、动态库及源码,在只安装office的电脑中,调用office打开PPT,在只安装WPS的电脑中,调用WPS打开PPT,在同时安装了office和WPS的电脑中,调用WPS打开PPT,支持上一页,下一页,跳到指定页,页码显示等操作。 立即下载

相关推荐

c++基于MFC操作PPT,打开PPT,新建并保存PPT等操作

vs2013导入PowerPoint,基于MFC操作PPT,打开PPT,新建并保存PPT等操作

vs2019 mfc office操作实现(word/excel/powerpoint)1--环境搭建

一、 office 365安装 我们采用的是OLE方式来操作文档,需要应用到office的标准库,如果没有安装MS office是无法获取对应库文件的。 1.安装office 365(版本为 2019),地址直接上MS官网获取就可以了。 2.安装完毕后,到安装目录下查看对应库文件是否存在。 二、vs2017 安装 原来用的是VS2019的,但是由于2019版本上去掉了“类型库添加..”的,重新下载vs2017。 1、从官方下载,不过当时访问报错了。大家可以自己试下看看。 2、独立下载非官.

4573

MFC实现简易绘图软件

使用MFC实现简易的绘图软件,基本上是使用鼠标拖动来绘制的图形,有直线,连续直线,矩形,圆,模拟曲线,多边形,圆弧 --------------------- 本文来自 辣条不爱辣 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/baidu_38304645/article/details/82821730?utm_source=copy

MFC通过COM操作在对话框中显示PowerPoint幻灯片(重点解决幻灯片全屏闪烁问题)

MFC通过COM操作在对话框中显示PowerPoint幻灯片,并解决闪烁问题

xhlzjd的博客 2163

MFC显示PPT

用MFC 显示PPT //启动 PowerPoint: void CMainFrame::OnPowerpointStartpowerpoint() { /// Check if the IDispatch connection exists with PowerPoint, // if not create one. if (m_ppt.m_lpDispatch == NULL) { // Create IDispatch connection to PowerPoint. m_ppt.CreateDispatch("PowerPoint.Application"); }; // Bring the PowerPoint application to the front. m_ppt.Activate(); } void CMainFrame::OnPowerpointStartslideshow() { _Presentation oPresentation; SlideShowSettings oShow; // Attach to the Active Presentation. oPresentation.AttachDispatch(m_ppt.GetActivePresentation()); // Attach to the slide-show settings. oShow.AttachDispatch(oPresentation.GetSlideShowSettings()); // Run the slide show. oShow.Run(); } // 创建幻灯片: void CMainFrame::OnPowerpointCreateslide() { // Connect to the active presentation. There is no error trapping. // If the active presentation the framework traps // the error and displays a message box. _Presentation ActivePresentation(m_ppt.GetActivePresentation()); // Connect to the slides collection. Slides oSlides(ActivePresentation.GetSlides()); // This constant is defined in the PowerPoint Object model. // You can use the Object Browser, with Visual Basic Editor // (VBE), to look up the different constant values. const ppLayoutTitleOnly = 11; // Add a new slide to the presentation. This code adds the new // slide to the end of the presentation. oSlides.Add(oSlides.GetCount() + 1l, ppLayoutTitleOnly); } // 创建演示文稿: void CMainFrame::OnPowerpointCreatepresentation() { Presentations PresCollection; // Make sure there is a dispatch pointer for PowerPoint. if(m_ppt.m_lpDispatch == NULL) { // Display a message indicating that PowerPoint is not running. MessageBox("PowerPoint is not running.", "Start PowerPoint"); } else { // Bring PowerPoint to the front. m_ppt.Activate(); // Attach the presentations collection to the PresCollection // variable. PresCollection.AttachDispatch(m_ppt.GetPresentations()); // Create a new presentation. PresCollection.Add(1);

MFC控制POWERPOINT操作

mfc控制powerpoint 对ppt进行打开、查询、关闭等操作;弊端是只针对.ppt后缀文件,不能对.pptx进行操作

MFC将视图文件保存到PPT中

MFC将视图文件保存到PPT中 源代码下载:http://download.csdn.net/detail/nuptboyzhb/4499649 借助微软提供的msppt.h 和 msppt.cpp文件,来开发有关ppt方面的软件。本例是将视图类View显示的画面,以图片的方式保存到ppt中。首先是将View转化为CBitmap对象中,然后将得到的图像保存到文件。再将保存的位图文件写入到ppt

郑海波(莫川)的CSDN博客 2872

MFC通过COM操作在对话框中显示PowerPoint幻灯片

MFC通过COM操作在对话框中显示PowerPoint幻灯片,在显示的过程中避免幻灯片全屏显示造成的显示效果差的问题,可以打开PPT、显示页码、切换到首页、切换到尾页、上一页、下一页以及关闭以及循环播放。

mfc 制作不同的文档模板mdi不同的子窗体_演示文稿powerpoint制作教程

演示文稿PowerPoint制作教程 内容简介: PowerPoint是用来制作演示文稿的软件,是一种强有力的表达观点、演示成果、传送信息的手段。利用PowerPoint提供的大量剪辑库和绘图工具,可以制作出精美的演示文稿幻灯片。本章主要介绍:演示文稿的创建、幻灯片制作工具的使用、处理幻灯片、插入对象、幻灯片效果设计、幻灯片放映技术等内容。学习重点:1.演示文稿的制作2.格式化和美化演示文稿3.动...

weixin_39941792的博客 319

MFC实现的平滑幻灯片播放效果

本资源是VS2008创建的工程 程序实现的是幻灯片平滑播放的效果 主要用于我的博文资源下载: http://blog.csdn.net/crocodile__/article/details/12975077

在PLC中将十六进制数据转换为浮点数(通常遵循IEEE 754标准)需要理解数据存储格式,并按以下步骤操作:

通过以上步骤,您可以在PLC中实现十六进制到浮点数的转换。T DBD20 // 将数据传送到浮点数变量(如DB1.DBD20)指数位(8位):实际指数 = 存储值 - 127(偏移量)。:必须确认PLC的存储顺序(大端或小端),否则结果错误。将两个16位寄存器合并为32位数据,需注意。尾数位(23位):隐含前导1,实际值为。:确保32位数据在寄存器中连续且对齐。符号位(1位):0表示正,1表示负。:高位寄存器在前(如西门子PLC)。:低位寄存器在前(如三菱FX系列)。,误差因截断导致)。

K11mvp的博客 4427

使用dsoframer演示ppt

优点: (1)不用直接打开PowerPoint (2)可以嵌入到Form中,那种先打开ppt然后将ppt嵌入到Form中的方式,会先打开PowerPoint 缺点: 很早就停止更新了。。。。 但是没办法还是这个好用 1.以管理员的身份运行程序 需要以管理员的身份运行程序(winform) 2.下载并注册dsoframer.ocx dsoframer控件注册,解注册和检查注册情况 ...

weixin_34148508的博客 1377

使用 pip 安装 pygame 遇到的问题

今天尝试学习使用 pygame 时,按照我的习惯一发 pip install 下去,本以为很简单的事情,没想到遇到了不少问题,顺手记录一下。 0x01. 无法找到 “SDL.h” 文件 pygame 是使用 SDL 库写就的游戏框架,自然强依赖于 SDL,我的 python@3 是使用 macOS 的 brew 管理器直接安装的,可能由于不是编译安装的问题,缺少了这个库,继续使用 brew 安...

Mitscherlich的博客 8626

VC6.0操作PowerPoint

File>New选择MFC AppWizard,项目名:PPT MFC AppWizard – Step1

WhereYouGo的专栏 1564

Grok-1.5+Ollama企业级本地化部署与合规实践指南

本文详细介绍了Grok-1.5+Ollama企业级本地化部署与合规实践指南,重点分析了本地化部署的成本优势和数据主权保障。通过RTX 4090显卡的硬件选型、Ubuntu 22.04系统优化及部署流程中的关键陷阱规避,为企业提供了高效、安全的AI模型部署方案。特别适合金融、医疗等敏感行业。

weixin_29094539的博客 186

Adams软件安装与配置全攻略:从入门到机器人仿真

机械系统动力学仿真软件Adams是工业机器人开发的重要工具,其安装过程涉及许可证配置、环境变量设置等关键技术环节。专业仿真软件安装通常需要处理系统兼容性、组件依赖和授权验证等工程问题,特别是在机器人控制仿真等场景中,还需集成MATLAB/Simulink等第三方工具。本文以Windows平台为例,详解Adams安装的核心步骤,包括系统环境检查、许可证服务器配置、工业机器人专项模块安装等实践要点,并针对NVIDIA Quadro显卡优化、27500端口通信等常见问题提供解决方案,帮助用户快速搭建可靠的仿真环境

weixin_28523493的博客 217

使用的 Microsoft 基础类 (MFC) 自动完成 Microsoft PowerPoint [草稿]

使用的 Microsoft 基础类 (MFC) 自动完成 Microsoft PowerPoint [草稿] 本文介绍如何通过使用 Visual c + + 5.0 或 Visual c + + 6.0 中使用的 Microsoft 基础类 (MFC) 自动完成 Microsoft PowerPoint。 回到顶端 | 提供反馈 更多信息 通过使用自动化在 PowerPoint 中

s3c44b0x的专栏 1556

人工智能(AI)简史:推动新时代的科技力量

人工智能(AI,Artificial Intelligence)是计算机科学的一个分支,旨在研究和开发可以模拟、扩展或增强人类智能的系统。它涉及多种技术和方法,包括机器学习、深度学习、自然语言处理(NLP)、计算机视觉、专家系统等。

qq_17153885的博客 1万+

VC操作PowerPoint

本文章讲解如何运用vc自动化操作PowerPoint。主要内容包括:启动、打开、关闭、播放、翻到首页、翻到末叶、翻到上页、翻到下页等。本代码以PowerPoint 2003为例,其他OFFICE组件及版本方法与此类似。下面是主要步骤和代码:1、创建MFC对话框应用程序,在向导的第3步选择automation,其他保持默认即可。2、在对话框上添加启动、打开、关闭、运行、播放、翻到首页、翻到末叶、翻到

施昌权专栏 2570

从拆箱到跑通:Intel RealSense D435i开箱实测+ROS驱动配置全流程

本文详细记录了Intel RealSense D435i深度相机的开箱体验,并提供了在Ubuntu 22.04与ROS2 Humble环境下,从安装librealsense2 SDK到配置ROS2驱动的完整流程。重点解决了驱动安装、数据流发布、点云对齐以及IMU数据融合等关键步骤,帮助研究者和开发者快速实现D435i与机器人系统的集成。

weixin_29168393的博客 310

通过WorkVisual连接KUKA机器人的具体方法

通过WorkVisual连接KUKA机器人的具体方法

Robot_PLC_HMI_Automation 6857

使用WebBrowser打开Powerpoint时只自动显示前两页的解决办法

有些时候在使用delphi的WebBrowser控件编写显示PPT(Microsoft PowerPoint)文档的时候(假设你欲显示的PPT已经设置成自动进行幻灯片切换),会出现WebBrowser只播放了前两页就停在那里不动了的情况。这时如果你用鼠标点一下WebBrowser右面的滚动条下方的箭头,会继续播放,如果你把PPT设置成了循环播放,也会顺利播放下去。这个问题产生的原因尚不知晓,也许是

netfirstman的专栏 3089

第二章:创建交互式地图

那么您应该已经有了一个安装了这些包的 conda 环境。否则,您需要创建一个新的 conda 环境并使用以下命令安装。

韩天放 4222

自动化操作PowerPoint

本文章讲解如何运用vc自动化操作PowerPoint。主要内容包括:启动、打开、关闭、播放、翻到首页、翻到末叶、翻到上页、翻到下页等。本代码以PowerPoint 2003为例,其他OFFICE组件及版本方法与此类似。下面是主要步骤和代码:1、创建MFC对话框应用程序,在向导的第3步选择automation,其他保持默认即可。2、在对话框上添加启动、打开、关闭、运行、播放、翻到首页、翻到末叶、翻到上页、翻到下页等按钮及函数。3、在应用程序的InitInstance()中初始化OLE,代码如下:// Init

ls39226542的专栏 729

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

上一篇: 如何使用 MFC 检索 Office 文档中的宏名称的列表
下一篇: 如何使用自动化来修改 Office 菜单
Augusdi
博客等级 码龄19年 1万+粉丝 1016原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值