My PhotoBruno Brás Silva

09, April 1986

info@brunosilva.net

Sintra Lisbon Portugal

Office System Add-in Development

Posted on 2:46pm 12/29/2007 by Bruno Silva in .NET, MS Office, Microsoft, Programming

Micrososft Office Power Point 2007

About a week ago I wrote a Power Point add-in which uses my XBox360GamePad Component to enable users to control a slide show with the XBox controller. Well, it’s kind of geek and maybe useless add-in, but it was a compelling objective who drove me to try MS Office development for the first time. It’s a shame that I don’t have a wireless controller… You can download this Add-in and have fun diving into the project code or just try it in a final user perspective by installing it in your Power Point 2007. I must warn you again that it will only work if you have XNA Game Studio 2.0 installed. I’m still trying to find out how to distribute this applications without this huge requirement.

Now I’ll leave here some tips/guidelines on MS Office development. I hope it will be useful if you want to start developing in this widely used software piece.

1. If you are working with Visual Studio 2005 you must install Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System. It also provides the prerequisites to develop for MS Office 2003. If you are working with Visual Studio 2008. These tools ship with the product.

2. Create a new project in Visual Studio. You can choose from a bunch of project templates by choosing the Office targeted version (2003 or 2007) and the application to which you’ll develop the add-in.

Visual Studio 2008 - Create new project

3. After you create an add-in project a file named ThisAddIn.cs will appear in the Solution Explorer. It has two event handlers: OnStartup and OnShutdown. I think that those names are self-explanatory. They are triggered on startup and shutdown of the add-in. There are 2 objects that you must know about to be able to interact with the Office application instance where the add-in is running. They are Globals.ThisAddIn and Globals.Ribbons. You can use the first one to access the context where the add-in is running and the document that is opened. The second one is used in MS Office 2007 development and allows you to manipulate the Ribbon.

Here I leave some properties, methods and events available in Globals.ThisAddin (note that inside the ThisAddIn.cs this object is equivalent to this keyword. If you have some more files that global object can be useful). These examples were extracted from a Power Point add-in.

  • Globals.ThisAddIn.Application.
    • ActivePresentation.Slides (property)
    • ActivePresentation.SlideShowWindow(property)
    • ActivePresentation.Save (method)
    • AfterNewPresentation (event)
    • SlideShowBegin (event)
    • SlideShowNextSlide

Just have fun exploring the API and I am sure you’ll find something useful to you. You can fill your plugin as you wish. You can add some windows forms triggered by some event or bind document contents to a database.

4. You can use Visual Studio to design Ribbon tabs or even add buttons to the MS Office applications main menu. Add a new item to your project and choose “Ribbon (Visual Designer)”.

Visual Studio 2008 - Ribbon Visual Designer

5. When you run this project in Visual Studio it starts a MS Office application instance allowing to debug your add-in.

6. Take a look at this entry in João Lívio (MVP) blog which links to some nice videos about MS Office development.

5 Responses to “Office System Add-in Development”

  1. You seem like a clever guy!
    Did you ever heard of GNU: http://www.gnu.org?

    Best wishes,

    tca

  2. Yes I have :)
    Actually, I use GNU licensed software often in both Linux and Windows.

    If your comment was written because you think something like “Who would write so much about proprietary software?” I just can say one thing. I like very much Microsoft technologies and like to explore them.
    I see this as an hobby and, in some way, a complementary learning aside from my academic learning which is more “Open source driven”.
    I believe in proprietary software. But by using proprietary software I am aware that we must be extra-careful in order to avoid being to much attached to a particular vendor.(Although I am not really applying this care in this blog, I admit.)

    I took a look at your blog and I really do think that applying software to teaching is great. And GNU software that matches the needs should be used. That is software making a difference in the real world. I don’t think though that Open Source is the right solution for each and every problem/situation.

    Best regards,
    Bruno S.

  3. Wrapping XNA framework classes is pretty overkill for reading the gamepads - plus it limits you to Xbox controllers only.

    Wrapping XInput is a pretty trivial task See these links and would remove the XNA dependency. native XInput would still need to be on the machine though (not part of standard DirectX)

    Wrapping DirectInput is harder but would give you few dependencies since you can rely on native DirectInput to be on most machines.

    Drop me an email if you want to go into more details of how to make this all work.

  4. Hi!
    I am aware of Xinput. I wasn’t able to put it to work…
    I installed DirectX 10 SDK, but in the DirectX Managed libraries XInput wasn’t present.
    I found an installer of Xinput driver on Microsoft but It didn’t install successfully.
    I tried DirectInput, I managed to see the gamepad capabilities, but I didn’t put it working to listen for gamepad changes.

    Any tips regarding XInput managed code support?
    It would be very useful. It awful the dependencies I have in that add-in. They make this add-in a developer only tool. And not even to the greatest part of developers, since XNA Game Studio 2.0 isn’t installed in most developers computer.

    Thanks in advance!
    Bruno Silva

  5. [...] here is a different use of the Xbox 360 Controller (With the help of the XNA Framework), Bruno has put together a simple office plug in for power point that will allow the user to use the Xbox 360 controller to control his [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Bruno Silva | Powered by Wordpress