Display PowerPoint Slide show within a VB form or control window

Source: Internet
Author: User

The example below shows the use of VB Form/control as a container application to display a PowerPoint slideshow. It as shows how to do use of a 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. '------------------------------------------------------------------------ Code within your own applications, add-ins, ' documents etc but is expressly forbidden from selling or ' otherwise dist Ributing this source code without prior consent. ' This includes both posting free demo projects made from the "Code as well as" the 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  as Object
 Public  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  as Integer)
    Dim  as Long
     on Error ResuNext
    Set Opptapp = CreateObject ("PowerPoint.Application")
    If  not  is  Then
        Set opptpres = OPPTApp.Presentations.Open (Show_file,,, False)
        If  not  is  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
                        
                        . 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  as  as Integer)
     on Error Resume Next
    Lblmessage.visible = True
    DoEvents
    If  not  is  Then
        Opptpres.close
    End If
    Set opptpres = Nothing
    If  not  is  Then
        Opptapp.quit
    End If
    Set Opptapp = Nothing
    Lblmessage.visible = False
End  Sub

Url:http://skp.mvps.org/vb/pptvbwnd.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.