' create a presentation and 1 empty slide with PowerPoint
' taken from Example01.vb

Private Sub Example01Main()

   ' start powerpoint 
   Dim powerApplication As PowerPoint.Application = New PowerPoint.Application()

   ' add a new presentation with one new slide
   Dim presentation As PowerPoint.Presentation = _
powerApplication.Presentations.Add(MsoTriState.msoTrue) presentation.Slides.Add(1, PpSlideLayout.ppLayoutClipArtAndVerticalText) ' save the document Dim fileExtension As String = GetDefaultExtension(powerApplication) Dim documentFile As String = String.Format("{0}\\Example01{1}", _
Application.StartupPath, _
fileExtension)
presentation.SaveAs(documentFile, _
PpSaveAsFileType.ppSaveAsDefault, _
MsoTriState.msoTrue) ' close power point and dispose reference powerApplication.Quit() powerApplication.Dispose() Dim fDialog As New FinishDialog("Presentation saved.", documentFile) fDialog.ShowDialog(Me) End Sub ''' <summary> ''' returns the valid file extension for the instance. for example ".ppt" or ".pptx" ''' </summary> ''' <param name="application">the instance</param> ''' <returns>the extension</returns> ''' <remarks></remarks> Private Function GetDefaultExtension(ByVal application As PowerPoint.Application) As String Dim version As Double = _
Convert.ToDouble(application.Version, CultureInfo.InvariantCulture)
If (version >= 12.0) Then Return ".pptx" Else Return ".ppt" End If End Function

Last edited Jun 13, 2012 at 12:47 PM by SebastianDotNet, version 7

Comments

No comments yet.