This project has moved and is read-only. For the latest updates, please go here.
' create ole chart object with PowerPoint
' taken from Example05.vb

Private Sub Example05Main()

   ' start powerpoint 
   Dim powerApplication As 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 chart slide.Shapes.AddOLEObject(120, 111, 480, 320, _
"MSGraph.Chart", "", MsoTriState.msoFalse, _
"", 0, "", MsoTriState.msoFalse) ' save the document Dim fileExtension As String = GetDefaultExtension(powerApplication) Dim documentFile As String = String.Format("{0}\\Example02{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 2:11 PM by SebastianDotNet, version 6

Comments

No comments yet.