1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 13 - Microsoft Office Applications and Managing Processes - Part 1

By Dan Mabbutt, About.com

5 of 9

VSTO Traps and Technicalities

VSTO presents technical traps for the unwary right from the initial installation. You must install Visual Studio.NET 2003 first because VSTO requires some internal components of VS.NET. Then, you should install Office 2003 next so the VSTO install can configure itself using those systems. Finally, you install VSTO last. If you do it in the wrong order, VSTO very likely won't work.

Once you get VSTO working, you discover more technical traps. Although VSTO gives you full access to the Word and Excel object models and IntelliSense statement completion for those models, the IntelliSense suggestions for VSTO might not work with the IntelliSense suggestions for VB.NET and this can lead to some confusion. For example, in the example "Hello About Visual Basic" program below, you might try assigning the color Red to the text in the Excel spreadsheet with a statement like this. (I did.)

~~~~~~~~~~~~~~~~~~~~~~~~~
myRange.Font.Color = System.Drawing.Color.Red
~~~~~~~~~~~~~~~~~~~~~~~~~

Intellisense suggests methods and properties for both the left and right sides of the statement. No syntax errors are created and when you run the code, no errors are shown. But it doesn't work. The problem is that the left side is the Excel object model and the right side is the VB.NET object model. And when a run time error is generated by VB.NET, Excel COM (which is actually in control and calls the VB.NET Assembly) just ignores the error.

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Automating Microsoft Office Applications and Managing Processes - Part 1

©2009 About.com, a part of The New York Times Company.

All rights reserved.