none
how to handle insert object in PPT with code. RRS feed

  • Question

  • Hi,Guys

    I want to pop-up insert object dialog to have user select and insert object by code , it works for word and excel, but for PPT ,i can't find any way to do it, any suggestion is appreciate.

    For example: in word we can do like below

    	Word::_wordApplicationPtr theApp((IDispatch*)m_spAppObj);
    	Word::_DocumentPtr ptrDoc=NULL;
    	HRESULT  hr = theApp->get_ActiveDocument(&ptrDoc);
    	if(FAILED(hr) || ptrDoc == NULL)	return dwRet;
    	BSTR bstrDest=NULL;
    	hr = ptrDoc->get_FullName(&bstrDest);
    	if(FAILED(hr)) return dwRet;
    	Word::DialogsPtr pDialogs = NULL;
    	hr = theApp->get_Dialogs(&pDialogs);
    	Word::DialogPtr pDlg =NULL;
    	wstring strPath;
    	switch(dwInsertType)
    	{
    	case emWordInsertObject:
    		pDialogs->Item (wdDialogInsertObject,&pDlg);
    		break;
    	case emWordInsertText:
    		pDialogs->Item (wdDialogInsertFile,&pDlg);  
    		break;
    	case emWordInsertPic:
    		pDialogs->Item (wdDialogInsertPicture,&pDlg);
    		break;
    	default:
    		return 2;
    	}
    	long lRet = 0;
    	pDlg->Display(&CComVariant(NULL),&lRet);  
    	if(lRet != -1)	return 1;
    	if(dwInsertType == emWordInsertText)
    	{
    		Word::wordOptionsPtr opPtr;
    		BSTR bstrFilePath=NULL;
    		theApp->get_wordOptions(&opPtr);
    		hr = opPtr->get_DefaultFilePath(wdDocumentsPath,&bstrFilePath);
    		if(SUCCEEDED(hr) && bstrFilePath != NULL)
    		{
    			strPath = bstrFilePath;
    			if(*(strPath.c_str()+strPath.length()-1) != L'\\')			strPath += L"\\";
    			SysFreeString(bstrFilePath);
    			bstrFilePath = NULL;
    		}
    	}
    how can we do for PPT?
    Monday, February 27, 2012 10:27 AM

Answers

  • Hello,

    The PowerPoint object model doesn't provide access to built-in dialogs. You can develop such a dialog yourself.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    • Marked as answer by china.tonny Wednesday, February 29, 2012 8:47 AM
    Monday, February 27, 2012 10:48 AM

All replies

  • Hello,

    The PowerPoint object model doesn't provide access to built-in dialogs. You can develop such a dialog yourself.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    • Marked as answer by china.tonny Wednesday, February 29, 2012 8:47 AM
    Monday, February 27, 2012 10:48 AM
  • That's not a good information for me ,it seems that developing such a dialog has a little bit complex.

    anyway,thanks for your update. Do you know where can i find an example that i can referrence?

    Tuesday, February 28, 2012 1:29 AM
  • I've never met such an example.

    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Tuesday, February 28, 2012 3:41 PM
  • ok, anyway, thanks for your reply.
    Wednesday, February 29, 2012 8:47 AM