If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
PowerPoint automation in C++: Error, There is no active presentation
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.Applic ation", &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 |
#2
|
|||
|
|||
PowerPoint automation in C++: Error, There is no active presentation
RAHUL wrote:
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. |
Thread Tools | |
Display Modes | |
|
|