Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i`m trying to learn about automating powerpoint using mfc,but my program is not executing properly plz help,here is my code


C++
LPDISPATCH		lpDispatch	= NULL;
	LPUNKNOWN		lpUnk		= NULL;
	HRESULT			hResult		= 0;
	CLSID			clsid		= {0};

	try
	{


	hResult = CLSIDFromProgID( L"PowerPoint.Application", &clsid);
    hResult = GetActiveObject( clsid, NULL,&lpUnk);
	if( hResult != 0)
	{
		hResult = CoCreateInstance( clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void **)&lpUnk);
	}

	hResult = lpUnk->QueryInterface( IID_IDispatch, (void **) &lpDispatch);
	lpUnk->Release();

	_Application theApp(lpDispatch);

    lpDispatch = theApp.GetPresentations();

	Presentations thePresentations(lpDispatch);
	lpDispatch = thePresentations.Add(0);
	}
	catch(...)
	{
	}
Posted
Updated 25-Aug-11 20:47pm
v2
Comments
CPallini 26-Aug-11 2:54am    
Could you please post here the details of the occurred exception?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900