Creating Power Point presentation on the fly with VB.NET

  • Thread starter Thread starter Boots
  • Start date Start date
B

Boots

Hi,

I'm creating a power point on the fly using VB.NET. The power point has
10 sheets with approx 500 text boxs in total. The problem I'm having is
performance. On one sheet I'm creating 130 boxs its taking approx 40
seconds to draw. Unfortunatly this is unacceptabe to the end user.

The code I'm using to add and format a text box is as follows:

Can anyone please help ? how can I increase performance ? what options
are open to me using VB.NET to create a powerpoint ?

Thanks,

Sub DrawPPTTextBoxFromControl(ByVal objSlide As PowerPoint.Slide, ByRef
objControl As Control)


Dim objNewObject

objNewObject =
objSlide.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationHorizontal,
objControl.Left, objControl.Top, objControl.Width, objControl.Height)

With objNewObject.TextFrame
' If blnWordwrap Then
.WordWrap = Office.MsoTriState.msoTrue
' Else
' .WordWrap = Office.MsoTriState.msoFalse
' End If
With .TextRange
If objControl.Text = "" Then
.Text = " "
Else
.Text = objControl.Text
End If
With .ParagraphFormat
' .Alignment
'.SpaceWithin = intParagraphSpacing
' .WordWrap = Office.MsoTriState.msoTrue
' .Bullet = blnBullet
End With
With .Font
.Name = objControl.Font.Name
.Size = objControl.Font.Size
.Bold = objControl.Font.Bold
.Italic = objControl.Font.Italic
.Underline = objControl.Font.Underline

End With
End With
End With
objNewObject.Visible = Office.MsoTriState.msoTrue
objNewObject = Nothing
End Sub
 
My guess is that PPT's trying to update the text objects as you modify them, or at
least as you release the reference to one and move onto the next.

One trick is to do something like this (in VBA; translations to VB.NOT are left as
an exercise for the more astute reader <g>)

' set the active view to some other slide
ActiveWindow.View.GoToSlide(x)
' now do your work on the real slide

' and return the view to the real slide
ActiveWindow.View.GoToSlide(objSlide.SlideIndex)

Slide X could even be some kind of "Please wait" slide that you create at the end
of the presentation and delete on the fly.
 
It appears creating Powerpoint presentations using VB6 or VB.NET is
pretty slow. What I did to improve performance was to write each
TextBox/Picture/Shapes/Table properties to an XML file. Then using a
Macro in Powerpoint read in the XML file and create the necessary
controls in Powerpoint.

A 9page/500 textbox presentation took 2 minutes to create in VB.NET now
takes 10 seconds in Powerpoint.

Thanks for all the suggestions.
Boots.
 
Back
Top