基于Visual C++2010 与office2010开发办公自动化(20)- 动态创建播放幻灯片

这篇博客介绍了如何利用Visual C++2010和Office2010的Interop功能,动态创建并播放PowerPoint幻灯片。内容涵盖VS2010新特性,如Word的Navigation Pane和协作功能,以及PowerPoint的幻灯片切换特效、视频处理和幻灯片分区。通过示例代码展示了如何在C++程序中插入和设置PowerPoint的图表和动画。
摘要由CSDN通过智能技术生成

VS2010新特性:

 

  Office Word 2010
  Office Word 2010 增强了 Navigation Pane 特性,用户可在 Navigation Pane 中快速切换至任何一章节的开头(根据标题样式判断),同时也可在输入框中进行即时搜索,包含关键词的章节标题会高亮显示。例如
  Office Word 2010 也增加了在线实时协作功能,用户可以从 Office Word Web App 中启动 Word 2010 进行在线文档的编辑,并可在左下角看到同时编辑的其他用户(包括其他联系方式、IM 等信息,需要 Office Communicator)。而当其他用户修改了某处后,Word 2010 会提醒当前用户进行同步。(注:此功能也存在于部分其他 Office 2010 程序中)
  另外,用户可在 Office Word 2010, Office PowerPoint 2010 以及 Office OneNote 2010 等 Office 2010 程序中直接插入其他正在运行的软件的截图。

 

 

 Office PowerPoint 2010
  Office PowerPoint 2010 除了新增更多幻灯片切换特效、图片处理特效之外,还增加了更多视频功能,用户可直接在 PowerPoint 2010 中设定(调节)开始和终止时间剪辑视频,也可将视频嵌入之 PowerPoint 文件中。
  PowerPoint 2010 左侧的幻灯片面板也新增了分区特性,用户可将幻灯片分区归类,也可对整个区内的所有幻灯片进行操作。见下图中的 Default Section 和 LiveSino Section。
  PowerPoint 2010 也增加了类似格式刷的工具 – Animation Painter,可将动画效果应用至其他对象,用法同格式刷。另外就是上次我提到的 Broadcast Slide Show 在线幻灯片播放功能。

 

 

 

好了不多说了,我们进入正题,看看在我们的应用程序中如何动态创建播放幻灯片

1.启动VS2010

 

用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);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尹成

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值