Working with Word Collections and using get_Item

Items in a Word collection are accessed in two different ways depending on whether the index into the collection is strongly typed or weakly typed.  In the case of the KeyBindings collection for example, the index is strongly typed as an integer.  As such, you can use the index operation ([]) to get to an…


Writing user defined functions for Excel in .NET

I’ve updated this article with some new guidance–for the details, see this post.  Excel enables the creation of user defined functions that can be used in Excel formulas.  A developer must create a special kind of DLL called an XLL.  Excel also allows you to write custom functions in VBA that can be used in…


When foreach in Excel goes wrong

This seems like a reasonable piece of code: For Each oCell As Excel.Range In Me.Range(“a1:b5”)  oCell.Value = “test”Next so does this: foreach Excel.CustomProperty prop in worksheet.CustomProperties{  Console.WriteLine(prop.Name);} Unfortunately, when you run this code you will get a “Missing member” exception.  Some collections in Excel can’t be “for-eached” over.  To do “foreach” the CLR has to…


More VSTO 2005 Video Magic

Kathleen has created two new videos you should check out.  Nice! Demo 5–How to Resize Excel Controls Demo 6 – How to Add Controls to the Actions Pane


Office Watsoning and Exceptions in VSTO 2005 Beta 1

[EDITOR’S NOTE] Blogging has been slow as we are spending almost all our time getting Beta 2 out the door. You may have had the experience of Excel or Word causing an Office Watson error at debug time when you have an exception that occurs in your Windows Forms event handlers in VSTO 2005. The…


Another plug.

I’ve been doing some C# development with the Excel object model and when you look at Excel objects in the object browser or in intellisense there are two major problems you run into: 1) Methods that would be hidden in VBA are shown in the object browser when using C#.  You really probably shouldn’t be…


FAQ: Why do my forms in my managed add-in or VSTO 2003 look Windows 95-ish

This is a frequent question that comes up. You develop a managed add-in or VSTO 2003 code behind.  You show a windows form and yuck–it looks like Windows XP never happened. The buttons aren’t pretty like the Windows XP buttons.  Everything looks circa Windows 95. The trick is you have to tell Windows Forms to use…


VSTO 2005 Video Magic

If you haven’t had a chance yet to see these great videos that Kathleen has made of VSTO in action, check them out.  They’re each about 6 minutes long are are really nice glimpses into some of the cool features of VSTO 2005.  Keep ’em coming Kathleen! Demo 1 – Locate and Delete NamedRange Controls…


More on getting Outlook to shut down

I recently posted some code showing how to get Outlook to shut down. I contended that you shouldn’t have to call ReleaseCOMObject as is shown in some MSDN articles to get Outlook to shut down. Indeed, David Mortenson who has worked on interop here at Microsoft warns further about ReleaseCOMObject. One other point that David…


This post brought to you by the letter E

On the very off topic subject of wacky things that happen to developers office’s, somehow one of the developers on my team (Mohit Gupta) has acquired a shower curtain complete with pressure rod which he has mounted on his office door.  To get in to his office, you have to open the shower curtain and…