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:
‘ 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

时间: 2024-10-09 14:09:25

Display PowerPoint slide show within a VB form or control window的相关文章

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

 #Region "WPF 当浏览器窗口关闭时触发 Quit事件 " #If OnSourceInitialized Then Protected Overrides Sub OnSourceInitialized(e As EventArgs) 'onload 等句柄创建后引用WSInitialized(Me, e) WSInitialized(Me, e) MyBase.OnSourceInitialized(e) End Sub #Else Private Sub LyWeb

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

1. 前言 我常常看到同一个应用程序中的表单的按钮----也就是"确定"."取消"那两个按钮----实现得千奇百怪,其实只要使用统一的Style起码就可以统一按钮的大小,而我喜欢更进一步将"确定"."取消"或其它按钮封装进一个自定义控件里. 这篇文章介绍了另一种ItemsControl的实现方式,并使用它为表单及自定义Window添加常用的按钮及其它功能. 2. 为Form添加FunctionBar 本来打算派生自ToolBa

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

 #Region "WPF 当浏览器窗体关闭时触发 Quit事件 " #If OnSourceInitialized Then Protected Overrides Sub OnSourceInitialized(e As EventArgs) 'onload 等句柄创建后引用WSInitialized(Me, e) WSInitialized(Me, e) MyBase.OnSourceInitialized(e) End Sub #Else Private Sub LyWeb

2017浙江省赛 E - Seven Segment Display ZOJ - 3962

地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3962 题目: A seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix

VB 中窗口发现冲突名称,将使用名称...怎么解决?

首先上图: 刚開始敲机房收费系统的时候就出现过这样的情况,当时有八个之多. 解决方法: (1)对窗口进行重命名(比如将frmGongZuoJiLu改成frmGongzuojilu),于是从8个错误降低到了5个. 剩下的3个对于这样的情况不适用. (2)发现我的frm文件里命名为frmXinXiWeiHu,例如以下: 可是我的窗口名字竟然是这种: 将两个名字改成同样的,利用这样的方法又使错误从3个降低到了2个. (3)剩下的两个顽固分子从机房開始到机房项目快结束了一直存留,昨天师傅开会提到了遇到问

VB打开工程时出现冲突名称提示

在敲机房时由于窗体命名不合适,我就修改了下窗体,但是保存后再打开的时候,却出现下面的提示: 这种情况出现,一般是由于引用了别人的窗体文件,或者是修改窗体的名字但是就是找不到任何冲突的地方.其实vb也是区分大小写的!解决如下: 找到提示错误的FRM文件,右键选择打开方式,选择记事本打开.注意最上面的几行,一般有Begin VB Form About(这里的About应该是你的窗体的名字,注意About的大小写).然后用记事本的"查找"功能找:Attribute VB_Name=,你会发现

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

第一个项目终于上线了,是一个叫亲青筹的公益众筹平台,微信端,电脑端还有后台界面大部分都是我完成的,几个月过来,感觉收获了很多,觉得要总结一下. 首先想到的是图片上传的问题.在通常表单数据都是ajax上传的情况下,为了上传图片而去使用form表单感觉很蠢.然后那时候也没有想到用jquery form插件. 后台的同事给的方案是用iframe里写一个form表单,然后上传图片之后自动提交表单,他将图片在服务器上的地址以跳转页url的一部分,我再来截取的方式. 方案一:iframe+form表单 <f

ExtJs 第二章,Ext.form.Basic表单操作

1.认识Ext.form.Panel表单面板         Ext.form.field.CheckBox 复选框 checkboxfield Ext.form.CheckBoxGroup 复选框组 checkboxgroup Ext.form.field.ComboBox 下拉列表框 combo Ext.form.field.Date 日期选择框 datefield Ext.form.field.Display 文本展示组件 displayfield Ext.form.FieldContai

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

最近在做项目的时候遇到一个需要上传文件的需求,因为ajax请求是无法上传二进制文件流的,所以只能用form表单提交,而form提交有一个问题就是会使页面刷新,本文解决了form表单提交文件时页面刷新的问题. 一.无刷新实现form提交文件 将form的target指向为一个iframe就可以实现无刷新提交文件了,但关键是还需要看到后台返回的数据,所以还需要为该iframe注册一个回调函数,因为iframe和该页面在同域内,所以可以在iframe里可以调用该回调函数,就可以看到后台返回的数据了.实