View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.powerpoint,microsoft.public.office.developer.vba
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Excel to Powerpoint Slow Execution

Why create powerpoint every time. Open it once. Do your work multiple
times. Close it once. (if you need to open file in powerpoint, do that,
but don't keep creating and closing powerpoint).

--
Regards,
Tom Ogilvy

"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