power point automation.
-
Hi, I have some powerpoint addins which are to be added to powerpoint programmatically.The problem in the below code is it always says power application object cannot be created while running the program. but powerpoint application object will create during debugging the program. hence I am not able to figure out the problem. Could any one help me please?
void InstallPptAddins(LPCTSTR strAddinPath)
{
CFileFind m_fileFind;
CString strAddin;PowerPoint::\_Application Ppt; //Powerpoint object PowerPoint::AddIns m\_pptAddIns; PowerPoint::AddIn m\_pptAddIn; if(!Ppt.CreateDispatch("PowerPoint.Application")) { Log("Error:fn::InstallPptAddins() Couldn't open Powerpoint Application\\n"); return; }
try
{if(Ppt.GetVersion()=="12.0") { PowerPoint::Presentations m\_Sets(Ppt.GetPresentations()); PowerPoint::\_Presentation m\_Set(m\_Sets.Add(TRUE)); strAddin = strAddinPath; strAddin += "DSAFO5PP.ppa"; if(m\_fileFind.FindFile(strAddin)) { m\_pptAddIns = Ppt.GetAddIns(); m\_pptAddIn = m\_pptAddIns.Add(strAddin); //Revove first if it already installed m\_pptAddIn.SetLoaded(FALSE); m\_pptAddIn.SetAutoLoad(FALSE); m\_pptAddIn.SetRegistered(FALSE); //Install the addins m\_pptAddIn.SetLoaded(TRUE); m\_pptAddIn.SetAutoLoad(TRUE); m\_pptAddIn.SetRegistered(TRUE); Log("AFO Powerpoint add-in is added.\\n"); } else Log("Couldn't find Powerpoint add-in %s\\n",strAddin);
}
catch(...)
{
Log("Error::Couldn't install Powerpoint add-ins.Please add it manually\n\n");
}Ppt.Quit();
}
-
Hi, I have some powerpoint addins which are to be added to powerpoint programmatically.The problem in the below code is it always says power application object cannot be created while running the program. but powerpoint application object will create during debugging the program. hence I am not able to figure out the problem. Could any one help me please?
void InstallPptAddins(LPCTSTR strAddinPath)
{
CFileFind m_fileFind;
CString strAddin;PowerPoint::\_Application Ppt; //Powerpoint object PowerPoint::AddIns m\_pptAddIns; PowerPoint::AddIn m\_pptAddIn; if(!Ppt.CreateDispatch("PowerPoint.Application")) { Log("Error:fn::InstallPptAddins() Couldn't open Powerpoint Application\\n"); return; }
try
{if(Ppt.GetVersion()=="12.0") { PowerPoint::Presentations m\_Sets(Ppt.GetPresentations()); PowerPoint::\_Presentation m\_Set(m\_Sets.Add(TRUE)); strAddin = strAddinPath; strAddin += "DSAFO5PP.ppa"; if(m\_fileFind.FindFile(strAddin)) { m\_pptAddIns = Ppt.GetAddIns(); m\_pptAddIn = m\_pptAddIns.Add(strAddin); //Revove first if it already installed m\_pptAddIn.SetLoaded(FALSE); m\_pptAddIn.SetAutoLoad(FALSE); m\_pptAddIn.SetRegistered(FALSE); //Install the addins m\_pptAddIn.SetLoaded(TRUE); m\_pptAddIn.SetAutoLoad(TRUE); m\_pptAddIn.SetRegistered(TRUE); Log("AFO Powerpoint add-in is added.\\n"); } else Log("Couldn't find Powerpoint add-in %s\\n",strAddin);
}
catch(...)
{
Log("Error::Couldn't install Powerpoint add-ins.Please add it manually\n\n");
}Ppt.Quit();
}