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:
' To locate the handle of the PowerPoint slideshow window
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的更多相关文章

  1. vb.net WPF webbrowser window.close 关闭后不触发 WindowClosing 事件 WNDPROC解决方式

     vb.net WPF webbrowser window.close 关闭后不触发 WindowClosing 事件 WNDPROC解决方式 #Region "WPF 当浏览器窗体关闭 ...

  2. 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 ...

  3. [WPF自定义控件库]为Form和自定义Window添加FunctionBar

    1. 前言 我常常看到同一个应用程序中的表单的按钮----也就是"确定"."取消"那两个按钮----实现得千奇百怪,其实只要使用统一的Style起码就可以统一按 ...

  4. VSTO PowerPoint 代码删除Shape后再恢复出现无法再次获取的问题

    做PowerPoint的VSTO插件项目,遇到个很奇怪的问题,当代码执行删除某些Shape时,没问题,但是操作Undo也就是恢复后,无法再次获取到之前删除的对象,这种情况只在Office2007中出现 ...

  5. html代码中的form参数是基本一致的

    由于pear的大多数模块仍处于开发当中,因此,这里列举的是随着php4.05一起发布的pear中的模块,需要注意的是,一些抽象类或者是基类(如mail.php,log.php,cache.php)没有 ...

  6. js实现无刷新表单提交文件,将ajax请求转换为form请求方法

    最近在做项目的时候遇到一个需要上传文件的需求,因为ajax请求是无法上传二进制文件流的,所以只能用form表单提交,而form提交有一个问题就是会使页面刷新,本文解决了form表单提交文件时页面刷新的 ...

  7. 项目回顾1-图片上传-form表单还是base64-前端图片压缩

    第一个项目终于上线了,是一个叫亲青筹的公益众筹平台,微信端,电脑端还有后台界面大部分都是我完成的,几个月过来,感觉收获了很多,觉得要总结一下. 首先想到的是图片上传的问题.在通常表单数据都是ajax上 ...

  8. css form 表单组对齐

    2014年7月1日 15:31:17 第一次写css,见谅 css: .form-box .form-group .form-label {text-align: right; width: 200p ...

  9. 用Autohotkey让powerpoint幻灯片一直播放

    有台电脑专门接了个大电视循环播放一个幻灯片,但是有时候会弹出一些对话框,比如windows要更新之类的,这样的话powerpoint就不是active的进城了,这样幻灯片就会停下来,还需要人去手动点一 ...

随机推荐

  1. 0629-TP整理四(create(),success(),error(),U())

    create()-前提:表单中name的值要与数据库中的字段一一匹配 可直接获取表单数据进行操作: 作用:将数据库中没有的字段在数组中去除. PHP中添加的语法如下: success()和error( ...

  2. ECMA里面的一元符

    只能操作一个值的叫做一元操作符.一元操作符是ECMAScript中最简单的操作符 1.递增和递减操作符 递增和递减操作符直接借鉴自c,而且各有俩个版本,前置型和后置型.顾名思义,前置型就是位于要操作的 ...

  3. Java 8 Stream API的使用示例

    前言 Java Stream API借助于Lambda表达式,为Collection操作提供了一个新的选择.如果使用得当,可以极大地提高编程效率和代码可读性. 本文将介绍Stream API包含的方法 ...

  4. 第八届河南省省赛 A.挑战密室

    挑战密室 时间限制: ms | 内存限制: KB 难度: 描述 R组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室.Dr. Kong必须尽快找到解锁密码逃离,否则几分钟之后,WT ...

  5. 三分 POJ 2420 A Star not a Tree?

    题目传送门 /* 题意:求费马点 三分:对x轴和y轴求极值,使到每个点的距离和最小 */ #include <cstdio> #include <algorithm> #inc ...

  6. 使用Oracle的DBMS_SQL包执行动态SQL语句

    引用自:http://blog.csdn.net/ggjjzhzz/archive/2005/10/17/507880.aspx 在某些场合下,存储过程或触发器里的SQL语句需要动态生成.Oracle ...

  7. STL内存分配方式

    关于STL用的很多比如map, vector, set, queue, stack等等.很少关注它的内存分配情况,但是经常遇到比如使用map,不停的在map中插入了一些很小的对象,然后释放了一些,然后 ...

  8. C# 代码笔记_文件

           string Route = @"D:\ksy\ksy\WebSite1\";//文件地址         string File_name = "user ...

  9. linux创建ftp用户以及指定目录问题

    linux创建ftp用户以及指定目录问题 创建用户命令:如我的目录是根目录下的 MyWeb 用户名:xdh2571 #useradd -G ftp -d /MyWeb -M xdh2571#passw ...

  10. Codewars练习Python

    计算一个数组的中间数,数的两边和相等,并返回index值 如:数组[1,2,3,4,6] 返回3(数组序号从0开始) def find_even_index(arr): ""&qu ...