Wednesday, 1 August 2012

How to Show Power Point Slide Show in Visual Basic

There are many way to show a power point slide show in vb form one can use OLE or a frame window
I'm showing it in a separate window. to show presentation do following steps

Make some declaration in general section 

  • Public oPPTApp As Object          
  • Public oPPTPres As Object
  • Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
          (ByVal lpClassName As String, _
           ByVal lpWindowName As Long) As Long
  • Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Function for show presentation

Private Sub slideShow() 
    Dim screenClasshWnd As Long
    Set oPPTApp = CreateObject("PowerPoint.Application")
    If Not oPPTApp Is Nothing Then
            Set oPPTPres = oPPTApp.Presentations.Open("Paste Your Presentation file path", , , False)
         If Not oPPTPres Is Nothing Then
             With oPPTPres                  
                          With .SlideShowSettings
                                 .ShowType = 1000
                                 .Run
                        End With
                Call SetWindowText(FindWindow("screenClass", 0&), APP_NAME)
        
        End With
       Else
        MsgBox "Error : Could not open the presentation.", vbCritical, APP_NAME
    End If
Else
    MsgBox "Could not instantiate PowerPoint.", vbCritical, APP_NAME
End If
End Sub

 

     

No comments:

Post a Comment