If you have been looking at my recent bookmarks, you may have
noticed a pattern: they all revolve around Excel and VSTO. The reason is that I
am starting multiple Excel development projects in the next few weeks. I am
very experienced in VBA and Office development, but after 4 years of writing C# code in Visual Studio, I have been spoiled, and VBA
suddenly feels very painful to work with, as if I were traveling back in time to the
middle-ages of development.
Fortunately, there is now an alternative: with VSTO, you can add custom features to
classic Office applications, using .NET languages and the comfort of Visual
Studio 2008. So I thought it was time to give VSTO a shot.
My first project was to establish a simple way to expose the
add-in functionality to the user through menus. I started from this article, and
adapted the code to encapsulate the menu-related behavior in one easy-to-use
class, the MenuManager.
The sample add-in works
with Office 2003 and 2007, and Windows XP and Vista. It installs an add-in which creates its own menu in Excel, “My Add-In”, containing two choices, “Do This” and “Do That”. When
these are clicked, message boxes pop up, displaying if the user has selected to "Do This" or "Do That",
and the name of the currently active sheet.
More...