none
Visual C++ Add-In for PowerPoint ? RRS feed

  • Question

  • Hallo there,

    I would like to create a Visual C++ Add-In for PowerPoint (2003-2010-etc)

    Could anyone give me a source code sniplet of how the Add-In could look like ?  Ive seen only C# examples, or does it mean making a Visual C++ Add-In doesnt make any sense ?

    How do I write an installer later on for this Add-In, and how this installer can put the Add-In into the Ribbon ?

    Thank you very much in advance!

    Thursday, November 1, 2012 7:26 AM

Answers

  • Hi BoStMS,

    Thanks for posting in the MSDN Forum.

    You can create a Shared Add-in to approach your goal, and Shared Add-in will create install project via itself.

    Following snippet create via machine, however you can modify it via yourself to fit your goal:

    // Connect.cpp : Implementation of CConnect
    #include "stdafx.h"
    #include "AddIn.h"
    #include "Connect.h"
    
    extern CAddInModule _AtlModule;
    
    // When run, the Add-in wizard prepared the registry for the Add-in.
    // At a later time, if the Add-in becomes unavailable for reasons such as:
    //   1) You moved this project to a computer other than which is was originally created on.
    //   2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
    //   3) Registry corruption.
    // you will need to re-register the Add-in by building the MyAddin1Setup project, 
    // right click the project in the Solution Explorer, then choose install.
    
    
    // CConnect
    STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication, AddInDesignerObjects::ext_ConnectMode /*ConnectMode*/, IDispatch *pAddInInst, SAFEARRAY ** /*custom*/ )
    {
     pApplication->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);
     pAddInInst->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pAddInInstance);
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnDisconnection(AddInDesignerObjects::ext_DisconnectMode /*RemoveMode*/, SAFEARRAY ** /*custom*/ )
    {
     m_pApplication = NULL;
     m_pAddInInstance = NULL;
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnAddInsUpdate (SAFEARRAY ** /*custom*/ )
    {
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
    {
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnBeginShutdown (SAFEARRAY ** /*custom*/ )
    {
     return S_OK;
    }

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 2, 2012 6:50 AM
    Moderator
  • Hi BoStMS,

    I'm not frequently use C++, however I have create shared add-ins which works for Office suites (Word, Excel, Outlook, PowerPoint, InfoPath, Access etc.). Shared Add-in can run on all of the Office suites or some specific application(It need you set manual). In the code which I mentioned you need get pointer of m_pApplication for your add-in. In this issue the pointer must point to PowerPoint application instance.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, November 5, 2012 4:53 AM
    Moderator

All replies

  • Hi BoStMS,

    Thanks for posting in the MSDN Forum.

    You can create a Shared Add-in to approach your goal, and Shared Add-in will create install project via itself.

    Following snippet create via machine, however you can modify it via yourself to fit your goal:

    // Connect.cpp : Implementation of CConnect
    #include "stdafx.h"
    #include "AddIn.h"
    #include "Connect.h"
    
    extern CAddInModule _AtlModule;
    
    // When run, the Add-in wizard prepared the registry for the Add-in.
    // At a later time, if the Add-in becomes unavailable for reasons such as:
    //   1) You moved this project to a computer other than which is was originally created on.
    //   2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
    //   3) Registry corruption.
    // you will need to re-register the Add-in by building the MyAddin1Setup project, 
    // right click the project in the Solution Explorer, then choose install.
    
    
    // CConnect
    STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication, AddInDesignerObjects::ext_ConnectMode /*ConnectMode*/, IDispatch *pAddInInst, SAFEARRAY ** /*custom*/ )
    {
     pApplication->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pApplication);
     pAddInInst->QueryInterface(__uuidof(IDispatch), (LPVOID*)&m_pAddInInstance);
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnDisconnection(AddInDesignerObjects::ext_DisconnectMode /*RemoveMode*/, SAFEARRAY ** /*custom*/ )
    {
     m_pApplication = NULL;
     m_pAddInInstance = NULL;
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnAddInsUpdate (SAFEARRAY ** /*custom*/ )
    {
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
    {
     return S_OK;
    }
    
    STDMETHODIMP CConnect::OnBeginShutdown (SAFEARRAY ** /*custom*/ )
    {
     return S_OK;
    }

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 2, 2012 6:50 AM
    Moderator
  • Thank you for replying.

    I just looked in the MSDN help. But they dont say, how exactly a Shared AddIn is to created. Any hint about it ? (Btw, they say : shared Add-in also works in Microsoft Office applications, such as Microsoft Word, Microsoft Visio, and Microsoft Excel. ---> Does it mean, it would not work for PowerPoint  ?!? )

    I googled one example for Outlook .. but it doesnt compile ...

    code.msdn.microsoft.com/office/Outlook-2010-Building-a-C-0358a023/view/SourceCode

    Any hint about it as well ?

    Friday, November 2, 2012 11:07 AM
  • Hi BoStMS,

    I'm not frequently use C++, however I have create shared add-ins which works for Office suites (Word, Excel, Outlook, PowerPoint, InfoPath, Access etc.). Shared Add-in can run on all of the Office suites or some specific application(It need you set manual). In the code which I mentioned you need get pointer of m_pApplication for your add-in. In this issue the pointer must point to PowerPoint application instance.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, November 5, 2012 4:53 AM
    Moderator
  • Hallo Tom_Xu,

    do you have a good example of a Shared Add-In in C++ which compiles ?

    Thanks in advance.

    Thursday, November 8, 2012 11:17 AM
  • Hi BoStMS2,

    There is a sample: http://www.codeproject.com/Articles/17781/ATL-COM-Shared-Add-Ins-Using-C-The-Easy-Way

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, November 13, 2012 6:38 AM
    Moderator