View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.powerpoint,microsoft.public.office.developer.vba
Howard Kaikow Howard Kaikow is offline
external usenet poster
 
Posts: 269
Default Excel to Powerpoint Slow Execution

Create the Powerpoint object only once, outside of the loop.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Francis de Brienne" wrote in message
om...
Thank you Tushar Mehta for your explanation. I new there was
something wrong with my instances of Powerpoint. I changed my
powerpoint declaration to your method but could still get Error 429
Cannot create activex component.

I know that the problem comes from the fact that opening and closing
powerpoint in a loop can do this type of problem. To remedy this, I
used the sleep method to give the application time to create the
object and everything works great. It only takes between 0.5 and 1.2
sec per slide, which is for me excellent speed because of all the
formating that I am doing.

So here is the sleep function for those who would need it and the
update to your code.

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)

Dim oPPApp As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
Dim pSlide As PowerPoint.Slide
Dim IStartedPP As Boolean

'AccessTime = Now()
On Error Resume Next
Set oPPApp = GetObject(, "Powerpoint.Application")
On Error GoTo 0
If oPPApp Is Nothing Then
IStartedPP = True
Sleep (200)
Set oPPApp = CreateObject("Powerpoint.Application")
Sleep (200)
End If
'MsgBox Format(Now() - AccessTime, "hh:mm:ss.s")

Thanks again for your quick reply