Is VSTO still alive?

Yes… you read it right!

Many people talk about Azure, HTML5, SilverLight, WindowsPhone 7, SharePoint etc. How many are talking about VSTO? Compared to other technologies, people who on talk on VSTO might be very less. But, the fact is that VSTO will exist and grow as long as there is a product called Microsoft Office exist!

Many people suggested me to retire from VSTO and choose some other technology as there is not much focus on it. But, VSTO is installed in my mind without ‘Uninstall’ option. Though I work on other technologies like Mobile Apps, ASP.NET etc., I always explore more about VSTO and love to get updates of it.

Actually, VSTO is not that bad as people think. It has very good features which address some issues which can’t be solved by other technologies. Some of the new features on Office 2010 like Backstage View, Ribbon Enhancements, Programmability refinements etc extends the programmability and make it ease.

When I have started working on VSTO, it is not shown in web search results (Bing or Google) until it is typed correctly. But now,  we have got many Video and Text Tutorials, Blogs, MSDN Library, exclusive forums to each office application and lot many. There is a lot of development in VSTO since last two years compared to before.

I thought to write a post on this after reading Ridi’s post – Is VSTO Dead?. Thanks Ridi!

Ridi recently spoke at Microsoft Innovation Roadtrip  and delivered several points on why Office programming is still valuable to give another benefits in organization productivity. He has shared few presentation decks on VSTO. Here is the Live Spaces link for it –

You can find Screen Casts, Tutorials and some downloadable content about VSTO 2010 here.

Happy Coding!

Deploying a COM Addin in 64-bit Office

Deployment alone is a hassle for VSTO Developers, especially beginners. In this, if one needs to deploy add-in in a 64-bit system is hectic. Here is a simple solution that I have used to debug and deploy add-ins in 64-bit Office.

You just need to follow these steps.
By default, the add-in will be registered with the respective office application. This is enough to run the application in debug mode. If we select ‘my add-in should be available to all users…’ option, it registers the add-in in the 32-bit global registry. This can be seen in RegEdit like this.

But, 64-bit Office cannot see registries in this location. For the add-in to load correctly, the registry keys should be moved to the following location.

For deploying the application…

In Visual Studio 2010, you just need to update the TargetPlatform property to x64 in the Setup Project Properties. Your project is ready to be deployed in 64-bit versions of Office now!

If you are working on Visual Studio 2008, there is a bug in setup project which prevents the add-in from registering 64-bit COM components. A work around is suggested for this problem in Cannot load 64-bit self-registering DLL’s section in Troubleshooting Windows Installer Deployments article in MSDN. It describes how to manually write 64-bit registry keys for making your add-in to work in 64-bit Office.

For more details, go through this article: Deploying COM Add-ins for 64-bit Office using Visual Studio

Saving mail content when a mail is sent from Outlook

To save the content of a mail item when it is sent, here is the procedure.

Private WithEvents itms As Outlook.Items

Private WithEvents SntFldr As Outlook.Folder

SntFldr = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)

itms = SntFldr.Items

Private Sub SaveMail() Handles itms.ItemAdd


End Sub

Before, I handled Application.Send Event and checked whether the Item is MailItem or not and then retrieved the content of that. But, with this, we couldn’t get the Date/Time and sending account information. So, opted for the above procedure.

UPDATE: Here is the updated sample code.

Private WithEvents SntFldr As Outlook.Folder
Private WithEvents itms As Outlook.Items

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
    SntFldr = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail)
    itms = SntFldr.Items
End Sub
Private Sub SaveMailAsMsg() Handles itms.ItemAdd
    If TypeOf itms.Item(itms.Count) Is Outlook.MailItem Then
        Dim olMail As Outlook.MailItem = itms.Item(itms.Count)
        MessageBox.Show("Item Added. " & vbCrLf & "Subject: " & olMail.Subject & vbCrLf & "From: " & olMail.SenderEmailAddress)
    End If
End Sub

Hope this helps!


‘inetreStrings’ – liked the nomenclature and the sense of humor of the author of it very much.

String vs string
Lower case string is simply an alias for System.String in the .NET Framework.

== or .Equals
A rule of thumb is that for almost all reference types e.g. objects, use Equals when you want to test equality. == compares whether two references (i.e. object instances) refer to the same object.
Primitive types can be compared for equality using ==, but in the case of strings, the variables on each side of the operators must be of type string.

Have a look at the following code and output, taken from Jon Skeet’s blog.

01    using  System;
03    public class Test
04    {
05    static void Main()
06    {
07    // Create two equal but distinct strings
08    string a = new string(new char[] {'h', 'e', 'l', 'l', 'o'});
09    string b = new string(new char[] {'h', 'e', 'l', 'l', 'o'});
11    Console.WriteLine (a==b);
12    Console.WriteLine (a.Equals(b));
14    // Now let's see what happens with the same tests but
15    // with variables of type object
16    object c = a;
17    object d = b;
19    Console.WriteLine (c==d);
20    Console.WriteLine (c.Equals(d));
21    }
22    }
23    The results are:
25    True
26    True
27    False
28    True

@ before a string
Using @ before a string means the escape sequences are not processed. This making it easier to write fully qualified path names for example.
@”c:\Docs\Source\a.txt” // rather than “c:\\Docs\\Source\\a.txt”

String objects are immutable, and so editing them, using Replace for example, results in a entirely new string being created, with new memory allocation. The original string is left intact in memory.
The StringBuilder class is designed for situations when one needs to work with a single string and make an arbitrary number of iterative changes to it. New memory allocation is not needed.

Came across the above on Bishop’s Blog while searching about something related to VSTO.

Developing add-ins for multiple versions of Office

Do you want to develop an add-in targeting multiple versions of Office? And you have basic questions like “Is it possible to do? ” and “How to do it?” ? Then you came to the right place. Few months back, I got a requirement to developed add-ins for Outlook 2003 and Outlook 2007. The functionality for both the versions is same. A doubt stroked… when the functionality is same, why would I develop two add-ins separately? Why don’t I make a single build for both the versions of Office?

Then I started searching for techniques to develop add-ins which works in both (2003 and 2007) and read many articles written by VSTO Experts in their blogs, Official VSTO Blog, MSDN, Forums and what not.

Misha Says:

Theoretically, you can develop an add-in for multiple versions of Microsoft Office by catering to the lowest common denominator. This means if you use an Excel 2003 add-in template in Visual Studio 2008, you would be able to develop and debug this with Excel 2007. However if you try this, you may meet these error messages: “You cannot debug or run this project, because the required version of the Microsoft Office application is not installed.”, followed by “Unable to start debugging.”

You can develop Office 2003 add-in in a system where Office 2007 is installed. The following is the procedure that demonstrates how to update your Visual Studio debugging options to use Microsoft Outlook 2007 to debug an add-in targeting Microsoft Outlook 2003.

  1. On the Project menu, click on ProjectName Properties
  2. Click on the Debug tab
  3. In the Start Action pane, click the Start external program radio button
  4. Click the file browser button and navigate to %ProgramFiles%\Microsoft Office\Office12
  5. Choose Outlook.exe and click Open
  6. Press F5 to debug your add-in

For more details. Go through this article in Misha Shneerson’s Blog.

There are some tips and tricks to be followed and the things that one needs to take care while developing add-ins targeting multiple versions of Office in Andrew’s Blog. Have a look at this too. You might find it interesting and useful.

Here is an MSDN article on Running Solutions in Different Versions of Microsoft Office

Hope this helps!

Awesome article on VSTO

Just came across an awesome article on ‘Visual Studio Tools for Office‘ written by Craig Bailey in his blog Its a brief story of VSTO narrated in simple words so that even beginners can understand it.

The post is written in interactive manner covering useful points like

  • What is VSTO?
  • Why VSTO?
  • How to start working with VSTO?
  • Some misconceptions on VSTO
  • Hurdles with VSTO

I am very much impressed with the article and would recommend this to VSTO entrants and enthusiasts to get a clear view of it. Hope you too will like it!

By the way, where is the link?

Here is it… 🙂

Building Powerful Applications for the Microsoft Office System Using VSTO

Here is a link from Microsoft Connect which I just came across… regarding a level 200 session on Building Powerful Applications for the Microsoft Office System Using VSTO. You can download the ZIP file from this page. It contains sessions and demos delivered by Tim Huckaby on VSTO which are helpful to the developers.

Here is the link