VC++ Powerpoint Automation application: Alway failed to call CPresentations::Open() under Powerpoint

Z

Zhaohui Xing

My PPT automation application calls CPresentations::Open() to open the source PPT file, the code work fine under PPT2003 and PPT2000 (Call OpenOld())

But alway failed in PPT2002 and during debuging, the error code in the exception is unknown. wried. Even I used progID "PowerPoint.Application.10", It always donot work.

Thanks

XZh

The sampel code is:

OleInitialize(NULL);

CApplication pptApp;

CLSID clsid;

if(FAILED(CLSIDFromProgID(OLESTR("PowerPoint.Application"), &clsid)))

{

return nRetCode;

}

if(!pptApp.CreateDispatch(clsid))

// if(!pptApp.CreateDispatch(_T("PowerPoint.Application.10")))

// if(!pptApp.CreateDispatch(_T("PowerPoint.Application"), 0))

{

TRACE(_T("Couldn't start PowerPoint and get Application object."));

return nRetCode;

}

pptApp.put_Visible(TRUE);

CPresentations pptPresentations = pptApp.get_Presentations() ;

// open a presentation

CPresentation pptPresentation = pptPresentations.Open(_T("c:\\dev\\outline.ppt"), FALSE, TRUE, TRUE);

OleUninitialize();
 
Z

Zhaohui Xing

The error code is 0x80004005
My PPT automation application calls CPresentations::Open() to open the source PPT file, the code work fine under PPT2003 and PPT2000 (Call OpenOld())

But alway failed in PPT2002 and during debuging, the error code in the exception is unknown. wried. Even I used progID "PowerPoint.Application.10", It always donot work.

Thanks

XZh

The sampel code is:

OleInitialize(NULL);

CApplication pptApp;

CLSID clsid;

if(FAILED(CLSIDFromProgID(OLESTR("PowerPoint.Application"), &clsid)))

{

return nRetCode;

}

if(!pptApp.CreateDispatch(clsid))

// if(!pptApp.CreateDispatch(_T("PowerPoint.Application.10")))

// if(!pptApp.CreateDispatch(_T("PowerPoint.Application"), 0))

{

TRACE(_T("Couldn't start PowerPoint and get Application object."));

return nRetCode;

}

pptApp.put_Visible(TRUE);

CPresentations pptPresentations = pptApp.get_Presentations() ;

// open a presentation

CPresentation pptPresentation = pptPresentations.Open(_T("c:\\dev\\outline.ppt"), FALSE, TRUE, TRUE);

OleUninitialize();
 

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