'------------------------------------------------------------------------' 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
|