Display PowerPoint slide show within a VB form or control window
The example below shows how to use VB form/control as a container application to display a PowerPoint slideshow. It as shows how to make use of an undocumented slide show setting to run the slideshow in a window of it's own without any PowerPoint toolbars.
System requirements:
Visual Basic 6.0 to compile the code
PowerPoint installed on the target system
Click here to download the VB project
![]() |
![]() |
|
' ------------------------------------------------------------------------
' Copyright ©1999-2011, Shyam Pillai, All Rights Reserved.
' ------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' ------------------------------------------------------------------------
Option Explicit Const APP_NAME = "PowerPoint in VB window" Const SHOW_FILE = "C:\PowerPoint\Sample.ppt" ' PowerPoint Constants Const ppShowTypeSpeaker = 1 ' Undocument constant used to display show in a window ' without PowerPoint command bars. Const ppShowTypeInWindow = 1000 Public oPPTApp As Object Public oPPTPres As Object ' API's used: Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As Long) As Long ' To set fram control as the parent of the slide show window Private Declare Function SetParent Lib "user32" _ (ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long ' To set the caption of the window Private Declare Function SetWindowText Lib "user32" _ Alias "SetWindowTextA" (ByVal hwnd As Long, _ ByVal lpString As String) As Long Private Sub cmdShow_Click(Index As Integer) Dim screenClasshWnd As Long On Error Resume Next Set oPPTApp = CreateObject("PowerPoint.Application") If Not oPPTApp Is Nothing Then Set oPPTPres = oPPTApp.Presentations.Open(SHOW_FILE, , , False) If Not oPPTPres Is Nothing Then With oPPTPres Select Case Index Case Is = 0 With .SlideShowSettings .ShowType = ppShowTypeSpeaker With .Run .Width = frmSS.Width .Height = frmSS.Height End With End With screenClasshWnd = FindWindow("screenClass", 0&) SetParent screenClasshWnd, frmSS.hwnd With Me .Height = 4545 .SetFocus End With Case Is = 1 With .SlideShowSettings .ShowType = ppShowTypeInWindow .Run End With Call SetWindowText(FindWindow("screenClass", 0&), APP_NAME) End Select End With Else MsgBox "Could not open the presentation.", vbCritical, APP_NAME End If Else MsgBox "Could not instantiate PowerPoint.", vbCritical, APP_NAME End If End Sub Private Sub Form_Initialize() With Me .ScaleMode = vbPoints .Caption = APP_NAME End With End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) On Error Resume Next lblMessage.Visible = True DoEvents If Not oPPTPres Is Nothing Then oPPTPres.Close End If Set oPPTPres = Nothing If Not oPPTApp Is Nothing Then oPPTApp.Quit End If Set oPPTApp = Nothing lblMessage.Visible = False End Sub |
url: http://skp.mvps.org/vb/pptvbwnd.htm
Display PowerPoint slide show within a VB form or control window的更多相关文章
- vb.net WPF webbrowser window.close 关闭后不触发 WindowClosing 事件 WNDPROC解决方式
vb.net WPF webbrowser window.close 关闭后不触发 WindowClosing 事件 WNDPROC解决方式 #Region "WPF 当浏览器窗体关闭 ...
- How to: Specify a Display Member (for a Lookup Editor, Detail Form Caption, etc.)如何:指定显示成员(用于查找编辑器、详细信息表单标题等)
Each business object used in an XAF application should have a default property. The default property ...
- [WPF自定义控件库]为Form和自定义Window添加FunctionBar
1. 前言 我常常看到同一个应用程序中的表单的按钮----也就是"确定"."取消"那两个按钮----实现得千奇百怪,其实只要使用统一的Style起码就可以统一按 ...
- VSTO PowerPoint 代码删除Shape后再恢复出现无法再次获取的问题
做PowerPoint的VSTO插件项目,遇到个很奇怪的问题,当代码执行删除某些Shape时,没问题,但是操作Undo也就是恢复后,无法再次获取到之前删除的对象,这种情况只在Office2007中出现 ...
- html代码中的form参数是基本一致的
由于pear的大多数模块仍处于开发当中,因此,这里列举的是随着php4.05一起发布的pear中的模块,需要注意的是,一些抽象类或者是基类(如mail.php,log.php,cache.php)没有 ...
- js实现无刷新表单提交文件,将ajax请求转换为form请求方法
最近在做项目的时候遇到一个需要上传文件的需求,因为ajax请求是无法上传二进制文件流的,所以只能用form表单提交,而form提交有一个问题就是会使页面刷新,本文解决了form表单提交文件时页面刷新的 ...
- 项目回顾1-图片上传-form表单还是base64-前端图片压缩
第一个项目终于上线了,是一个叫亲青筹的公益众筹平台,微信端,电脑端还有后台界面大部分都是我完成的,几个月过来,感觉收获了很多,觉得要总结一下. 首先想到的是图片上传的问题.在通常表单数据都是ajax上 ...
- css form 表单组对齐
2014年7月1日 15:31:17 第一次写css,见谅 css: .form-box .form-group .form-label {text-align: right; width: 200p ...
- 用Autohotkey让powerpoint幻灯片一直播放
有台电脑专门接了个大电视循环播放一个幻灯片,但是有时候会弹出一些对话框,比如windows要更新之类的,这样的话powerpoint就不是active的进城了,这样幻灯片就会停下来,还需要人去手动点一 ...
随机推荐
- bzoj 4424: Cf19E Fairy && codeforces 19E. Fairy【树形dp】
参考:https://blog.csdn.net/heheda_is_an_oier/article/details/51131641 这个找奇偶环的dp1真是巧妙,感觉像tarjan一样 首先分情况 ...
- 洛谷2019 3月月赛 T4
T3做不来.. 直接滚去T4 orz 乍一看 T4是个DP 题干 复杂度??(N^4) 咋优化... 还带一只捆绑 捆绑啥的最烦人了 最后20pts 直接废了 T了 很烦 不过拿到80pts已经很开心 ...
- 用Google Cloud Platform搭建***服务教程
之前FQ一直用的是***,天有不测风云,前几天发现ss服务挂了.更可怕的是ping都ping不通,多方打听,***中文社区已经炸开锅了,原因就是IP被封了.需要付费更换IP.然后到现在还是没有给我更换 ...
- [Qt Quick入门] 基本元素初体验
Qt Quick作为QML语言的标准库,提供了很多基本元素和控件来帮助我们构建Qt Quick应用.这节我们简要地介绍一些Qt Quick元素,如Rectangle.Item.Text.Button. ...
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
Let SS be a sequence of integers s_{1}s1, s_{2}s2, ......, s_{n}snEach integer is is associ ...
- svn报错:Cannot negotiate authentication mechanism
在使用eclipse的svn插件连接osc的代码仓库时候,发生了以下错误: Cannot negotiate authentication mechanismsvn: Unable to connec ...
- Android requestWindowFeature(Window.FEATURE_NO_TITLE)无效解决方法
今天在<第一行代码>上学习做自定义标题栏,需要将系统自带的标题栏隐藏掉,使用自定义的标题栏,结果发现,requestWindowFeature(Window.FEATURE_NO_TITL ...
- JDBC性能优化
一.使用PreparedStatement的Batch功能 参见本人一下文章:http://blog.csdn.net/lmb55/article/details/50631062 二.选择合适的光标 ...
- My-Eclipse 快捷键大全
Ctrl+1 快速修复(最经典的快捷键,就不用多说了) Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加) Ctrl+Alt+↑ 复制当前行到上一行(复制增加) Alt+ ...
- SQL SERVER 2008 在某表中新增一列时失败
背景:新增列语句如:“alter table 表名 add 列名 float default 0 with values”(用VS2010做网站,这句话是在C#代码里执行的) 报错提示: 警告: 已经 ...