OdeToCode IC Logo

That Wacky Office API

Friday, May 27, 2005

Like Ben @ CodeBetter, I admire the power behind the Office API. We finally have some customers buying into the promise of smart clients, and it is amazing to see the amount of functionality available through the object model of Word, Excel, and the rest of the family.

But, after reviewing the code, I still think it sucks. The rough edges of interop poke out in every corner, and the constant appearance of Sytem.Object in parameter lists and return values ruins the discoverability.

object currentDateBookmark = "CurrentDate";

Word.Range range =

    thisDocument.Bookmarks.get_Item(ref currentDateBookmark).Range;

"Quit whining", I hear you say. "There is a leaning curve involved". Yes, there is a leaning curve, but even once you have the vocabulary down there is unattractive code involved.

CategoryList = commandBar.Controls.Add(






    ) as Office.CommandBarComboBox;

Ok, this is unattractive C# code. Make no doubt about it, Office automation currently looks best in VB.NET.