Re: powerpoint automation via vb.net

Tech-Archive recommends: Fix windows errors by optimizing your registry



HI!

here is the code. also, if its 30 rows in a row it takes about 10-15min to
render all the ppt as it will be 60 slides. could you also possibly suggest
how could i speed up automation.

------------------------------------------------------
Try
If
Len(Trim(dr.Item(Strings.Right(Trim(ppItem.TextFrame.TextRange.Text),
Len(Trim(ppItem.TextFrame.TextRange.Text)) - 1)))) > 0 Then

Dim s As String =
dr.Item(Strings.Right(Trim(ppItem.TextFrame.TextRange.Text),
Len(Trim(ppItem.TextFrame.TextRange.Text)) - 1))
s = s.Trim
Dim newStr As String
newStr = Replace(s,
Chr(224), " ")

ppItem.TextFrame.TextRange.Text = Replace(newStr, Chr(10), "")

Dim a, b, looplen As Integer

Dim starts, ends, length As
Integer
looplen = s.Length

Dim hashWords As String()

Dim strWord As String

For a = 0 To looplen - 1
If s.Substring(a, 1) =
Chr(224) Then
starts = a
a += 1

For b = 1 To looplen
- 1

If
s.Substring(a, 1) = Chr(224) Then

ends = a

length =
ends - starts + 1

ppItem.TextFrame.TextRange.Characters(starts, length).Font.Bold = True

strWord = ""

Exit For
End If

strWord +=
s.Substring(a, 1)
a += 1
Next

End If
Next
Else
ppItem.Visible =
Microsoft.Office.Core.MsoTriState.msoFalse
End If
Catch

End Try
End If
End If
Next
Next

ppTarget = Nothing


Next

ppApp.WindowState =
Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMaximized
'Modify the slide show transition settings for all 3
slides in
'the presentation.

With ppPres.Slides.Range(SlideIdx).SlideShowTransition
.AdvanceOnTime = False
' .AdvanceTime = 3
.EntryEffect =
Microsoft.Office.Interop.PowerPoint.PpEntryEffect.ppEffectBoxOut
End With

'Prevent Office Assistant from displaying alert messages.
ppApp.Assistant.On = False
End If
ElseIf (Not isCorrectFileType) Then
MessageBox.Show("The selected Powerpoint template is not
valid. It must have a 'ppt' file extension.", "Order Form", _
MessageBoxButtons.OK, MessageBoxIcon.Warning)

Else

MessageBox.Show("There are no titles with which to generate
the presentation", "Order Form", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Catch
Throw
Finally
'Reenable Office Assisant, if it was on.
If assistantOn Then
ppApp.Assistant.On = True
ppApp.Assistant.Visible = False
End If


ppTarget = Nothing
ppItem = Nothing
ppPres = Nothing
ppApp = Nothing

' This is important because we want the GC to clean up our
memory from unmanaged code (eg COM interop to powerpoint)
GC.Collect()

MyBase.RaiseShowProgress(False, 1, 100, 1)
MyBase.RaiseUserMessage("")
Cursor = Cursors.Default
End Try
----------------------------------------------------


cheers



"Steve Rindsberg" wrote:

In article <864C6E35-829D-4739-8B3D-17DFC182FA5D@xxxxxxxxxxxxx>, Bikash wrote:
Hi!

This really solved my problem but i ran into another issue.

I am sending list of rows from datagrid to powerpoint. each row represents 2
standard slide which is being rendered using a 2slided master slide. now the
problem is the first row becomes the last powerpoint slide and last row
becomes first powerpoint slide. how could i render those rows so that 1 row
becomes 1slide in powerpoint.

Hard to say w/o looking at the code.

But if you insert a list like this:

One
Two
Three

into PPT by inserting a new slide at the same index, say 2, each time you'd get:

Existing slides
One
Existing slides

then

Existing slides
Two
One
Existing slides

then

Existing slides
Three
Two
One
Existing slides

You need to change the index at which you insert the slide to account for the other
slides you've already inserted.




.


Quantcast