Create a Videos Programmatically in MS PowerPoint 2010 in VB.NET

In this article I am going to explain about how to Create a Videos Programmatically in a Microsoft PowerPoint 2010 presentation.
  • 2537

 Introduction

In this article I am going to explain about how to Create a Videos Programmatically in a Microsoft PowerPoint 2010 presentation. For this we use CreateSampleVideo, CreateVideo methods in Microsoft PowerPoint 2010.

Microsoft Office 2010 offer some powerful tools, using this tools you can create application. Using Microsoft Visual Basic for Applications (VBA) you can create your own application according to your need. These application can performer some specific task.

For creating application we can use

  • VBA host of Excel 2010
  • VBA host of PowerPoint 2010
  • VBA host of Word 2010

NOTE : OneNote 2010 is not a VBA host.

Code that we use in this application are given below

Sub TestCreateSampleVideo()

    CreateSampleVideo(ActivePresentation, "C:\Temp\Video.wmv")

End Sub

 

Sub CreateSampleVideo(pres As Presentation, fileName As String)

    

    pres.CreateVideo(fileName, DefaultSlideDuration:=1, VertResolution:=480)

 

    ' Now wait for the conversion to be complete:

    Do

        ' Don't tie up the user interface, add DoEvents

        ' to give the mouse and keyboard time to keep up.

        DoEvents()

        Select Case pres.CreateVideoStatus

            Case PpMediaTaskStatus.ppMediaTaskStatusDone

                MsgBox("Conversion complete!")

                Exit Do

            Case PpMediaTaskStatus.ppMediaTaskStatusFailed

                MsgBox("Conversion failed!")

                Exit Do

            Case PpMediaTaskStatus.ppMediaTaskStatusInProgress

                Debug.Print("Conversion in progress")

            Case PpMediaTaskStatus.ppMediaTaskStatusNone

                ' This shouldn't happen--you'll get this value

                ' when you ask for the status and no conversion

                ' is happening or has completed.

            Case PpMediaTaskStatus.ppMediaTaskStatusQueued

                Debug.Print("Conversion queued")

        End Select

    Loop

End Sub

Steps for creating Application

Step 1 : Start Microsoft PowerPoint 2010 :

 1.jpg

Step 2 : Using Alt + F11 Key Start Visual Basic for Applications (VBA) Window :

2.jpg

Step 3 : Select on VBAProject(Presentation 1) : 

3.jpg

Step 4 : Right Click On VBAProject(Presentation 1) ==> Goto Insert==> Goto Module & click on Module:

4.jpg

5.jpg

Step 5 : Write Code in Visual Basic for Applications (VBA) Window :

Clipboard02.jpg

Step 6 : Run Application using F5 :

Step 7 : Macros window will open, Select Macros name and click on Run Button :

Clipboard04.jpg

Step 8 : Output of Application :

Clipboard08.jpg
 

Clipboard06.jpg

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.