This project has moved. For the latest updates, please go here.
' create some kind of shapes with PowerPoint
' taken from Example02.vb

Private Sub Example02Main()

   ' 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) Dim slide As PowerPoint.Slide =
presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank) ' add a label Dim label As PowerPoint.Shape = slide.Shapes.AddLabel( _
MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 600, 20) label.TextFrame.TextRange.Text = _
"This slide and created Shapes are created by NetOffice example." ' add a line slide.Shapes.AddLine(10, 80, 700, 80) ' add a wordart slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, _
"This a WordArt", "Arial", 20, _ MsoTriState.msoTrue, MsoTriState.msoFalse, 10, 150) ' add a star slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250) ' 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:58 PM by SebastianDotNet, version 12

Comments

No comments yet.