PowerPoint automation in C++: Error, There is no active presentation

R

RAHUL

Hi All,

I am doing office automation in my C++ application using the folloing
code. Most of the time the code runs fine, but on some windows XP
machines with PowerPoint 2003 (11.8307.8221 SP3) installed the source
line marked with "ERROR" throws exception saying "Invalid request.
There is no active presentation.". If I reexecute the code on this
machine then it runs successfully (The error comes for the first time
only)
i.e. If POWERPNT.exe is already running in background then the error
never comes, But the error always come on that machine when the code
is run first time.

Is this happening due to some corrupt installation or registry value?
Is there a way to get more information as "why is the error
happening"?
Any help is greatly appreciated.

CApplication powerPointApp;
COleException exception;
if (!powerPointApp.CreateDispatch(L"Powerpoint.Application",
&exception))
{
CPresentations presSet(powerPointApp.get_Presentations());
CPresentation thempPPT(presSet.Open(strTempFileName, // Filename
true, // Readonly
false, // Untitled
false // WithWindow
));

VARIANT vtIndexSrc;
vtIndexSrc.vt = VT_I4;
vtIndexSrc.lVal = 1; // The PPT file always have 1 slide

CSlides tempPPTSlides(thempPPT.get_Slides());
CSlide singleSlide(tempPPTSlides.Item(vtIndexSrc)); // "ERROR"
}


Thanks in advance
Rahul
 
S

sasha

RAHUL said:
Is this happening due to some corrupt installation or registry value?
Is there a way to get more information as "why is the error
happening"?
Any help is greatly appreciated.


I would imagine that something hasn't had a chance to fully
load/initialize by the time you are trying to get slides. Either process
an event (ready, loaded - whatever are they?) or insert a small wait period.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top