
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.

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)”.

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.

In the last few days I’ve been working with theVirtual Earth API in my spare time. I made a demo application of Virtual Earth. In this demo I used a Windows Forms application to wrap a Virtual Earth (VE) map (which is loaded in a HTML page into a WebBrowser control).
In that HTML page I added some Javascript functions that wrap the VE API in some functions which I call via the WebBrowser control. This way I can manipulate the map in Windows Forms. I’ve added support to my XBox 360 GamePad Component. You can use your game pad to pan and zoom in/out in the 2D map. You can also switch between map styles (road,aerial, hybrid, bird’s eye). This is still a developer’s toy, since you need XNA Game Studio 2.0 installed to be able to run this application. Oh, and you also need .NET Framework 3.0.
I was surprised when I found out that the beta 3D view in VE natively supports the XBox 360 controller.
The least but the last feature I added was support for Microsoft Speech. I added a welcome message, and if you say the name of a country (in English) the map moves into that country (or to be more specific, to the country name that the application understood…). I’ve achieved this by loading a XML file, which I found over the web, that contains the name of many countries (not sure if contains them all). After loading this file the code is pretty similar to my previous post about Microsoft Speech.
That’s all! I’ll be pleased to answer some doubts and hear suggestions about this demo.

I’ve been wanting to try out System.Speech namespace (present in 3.0 and 3.5 .NET Framework) but unfortunately until this weekend I was stuck with a Portuguese version of Windows Vista which prevented me from using Speech features.
Today I finally tried it out and I was stunned! It couldn’t be simpler (at least for a simple example
). I’ll explain in a few lines of code how to use two main features: Speech Synthesis and Speech Recognition.
Speech Synthesis
using System.Speech.Synthesis;
To make your computer to say something is as simple as 2 lines of code can be:
synthesizer = new SpeechSynthesizer();
synthesizer.Speak("Hello World");
This piece of code has one disadvantage: it locks your program until “Hello World” is said. You can achieve the same goal without this problem by using a asynchronous approach.
// Shut up any speaking going on
if (synthesizer.State == SynthesizerState.Speaking)
synthesizer.SpeakAsyncCancel(
synthesizer.GetCurrentlySpokenPrompt());
// Say text (Async to prevent blocking)
if (synthesizer.State == SynthesizerState.Ready)
synthesizer.SpeakAsync("Hello World");
Speech Recognition
using System.Speech.Recognition;
Speech recognition requires a setup with more code, but as simples as synthesis.
sre = new SpeechRecognitionEngine();
/// Recognize from default Microphone
sre.SetInputToDefaultAudioDevice();
/// Grammar with the words you want to recognize
GrammarBuilder grammarBuilder = new GrammarBuilder();
grammarBuilder.Append(
new Choices("start", "stop", "pause", "restart", "go back"));
Grammar customGrammar = new Grammar(grammarBuilder);
sre.UnloadAllGrammars();
sre.LoadGrammar(customGrammar);
/// Handler to be run in each recognition
sre.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>
(sre_SpeechRecognized);
/// Do not stop recognizing
sre.RecognizeAsync(RecognizeMode.Multiple);
You have to program a handler which will be used to handle the recognized text in the way that most pleases you.
void sre_SpeechRecognized(object sender,
SpeechRecognizedEventArgs e){
/// Store recognized text
txbDebug.Text += e.Result.Text + "\r\n";
}
You can download my first Speech application to see it working 

This Christmas a friend gave me a Xbox wired controller. I don’t have a Xbox 360, but I wanted to try XNA development and use the controller to develop some different user-interfaces on windows-based applications. This weekend I managed to put the first pieces to work
Based on XNA framework which has support for Xbox 360 controller I built an component that you can drag and drop into your windows forms application. You can assign each control instance to a different controller (up to 4) and set the interval between hardware changes checking (the default is 100 miliseconds). This component raises events when the controller status changes. It has a general onChange event, and an event for each button, trigger and stick status change. It has also a method to control the controller vibration.
This component is not a big deal. When it is instantiated, the component creates a new thread which waits for a period of time before returning into the main thread. When it returns it checks for controller changes using the Microsoft.Xna.Framework.Input.GamePad class. This check is made by comparing the current GamePadState with the previous one. For each change it is raised an event to which you can subscribe in your windows application. I tried to use it in a WPF application. It worked, but I had to create the component in code. It didn’t appear in the toolbox.
You can download the component source code and an example here. I added some comments into the code, but I think that it is pretty simple to understand even to people with little experience with C#. Any question/suggestion feel free to comment!
I’ve tried it in a virtual machine in order to find out the software requirements. I had to install XNA Game Studio 2.0 to put it to work… The XNA redistributable wasn’t enough. If someone can tell me how to distribute my examples with minimum software requirements I’ll be glad to hear from you
This is also a great change for you to try Visual Studio 2008, since the solution in the zip package has to be opened in VS2008. If you don’t have access to this software, or you’re having trouble migrating the code into a VS2005 environment just tell me, and I will help you out.
As soon as I develop some applications using Xbox controller I’ll publish them here in my blog.

MS Press has just released an e-book on Visual Studio 2008 technologies and are giving it away for free. The e-book includes excerpts from three recent book releases and provides a wealth of information and insights from top experts:
You can see the first chapter of these books for free. When you register, you’ll be able to download a lot more content of those books, packaged as an e-book.
I just want to leave this reference to a blog where you can find some XNA webcasts made by some Italian students.
http://xnalearners.spaces.live.com