Amazed by .NET & COM Iter-Op

A non-programming friend of mine recently needed a fairly simple office add-in written. Rather than responding with the more usual “write it your [dam] self” answer I took a more understanding approach (OK, so promises of money may also have been involved) and wrote it for him. I had done some .NET & COM inter-op, and it seemed to work OK in the past (despite some of the bad things I have since heard about it - maybe I was just lucky). I decided to try and write it in .NET just to “see if it would work”, fully expecting to have to break out the VB6 disks at some point and write it in that, or switch to VBA. I quickly found this article;en-us;302901 and followed the steps outlined. That simple demo worked. I wrote some code, and that worked too. I needed to get a hold of the word application object, so I added a reference to word, and cast the generic application object (who was being passed in as an object from a method signature in the Extensibility dll) to a “word” application (from the word COM dll) - that worked. Several times I said to myself “now this is probably not going to work” and each time I was pleasantly proven wrong. This is using vanilla VS 2003. No VSTO or anything like that, and it all just worked. Apart from one hiccup when multiple word documents were open I had no problems. Total time spent was a couple of hours, and no need to resort to nasty VB6 or VBA. It runs in Word 2000 up to Word 2003. I have not tried (nor do I care to try) Word 97. Yay .NET COM inter-op.
My experience is something of a contrast to Geoff’s

In other news long-time ‘blogging hold-out Adrian has finally gotten himself a weblog. His Java/Linux tendencies made it hard to convince him to become a “.NET Junkie”. Here is a CSS trick form him on getting MSDN code samples to display properly in Firefox browsers.


HowTo: Control which version of the framework your office add-ins run under
15/08/2004 2:10:00 AM