open Powerpoint main window and display a PPT file with automation

D

David

Hi,

I am now using C++ and Powerpoint automation interface to create a
powerpoint file and save it. That works fine. Now, I want open that document
with Powerpoint when the file is successfully created.

I am coding like the following:

------------------------------------------------------------------------
// Get DISPID for the Open method on the Presentations collection object
szFunction = OLESTR("Open");
hr = pDispPrsCol->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_PrsColOpen);

VARIANT vArgsOpen[1];
DISPPARAMS dpOpen;

vArgsOpen[0].vt = VT_BSTR;
vArgsOpen[0].bstrVal = bstrTemp;
dpOpen.cArgs = 1;
dpOpen.cNamedArgs = 0;
dpOpen.rgvarg = vArgsOpen;

// Open the saved Powerpoint presentation by invoking the open method
hr = pDispPrsCol->Invoke(dispid_PrsColOpen, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &dpOpen, NULL, &excep, NULL);
if(FAILED(hr)) OLEErrHandler(hr, excep);

::SysFreeString(bstrTemp);
--------------------------------------------------------------------------

But the program gives error message:
Run-time error: Presentations.Open: Invalid request. The Powerpoint frame
window does not exist.

So, from the error message, I guess I need to launch Powerpoint main frame
window first.

Can anyone let me know how to launch Powerpoint main frame window?

Thanks a lot!
 

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