Skip to content

COM Testing Support

Purpose

Microsoft's Component Object Model (COM) is a standard for communication between separately engineered software components (source).  Any object with a COM interface can be created and used remotely.

Usage

Creating a COM Object

You can create a COM object using Windows' ActiveXObject class.  Once the object is created, method invocation is the same as with any other object in your program.  The methods available will depend on the object's COM interface.  The following example shows how to create an instance of the Word application and open a file.

var doc = new ActiveXObject("Word.Application");
doc.Documents.Open(wordFileName);

Test Samples

There are several test samples that show how to Unit Test application modules via COM interface:

  • UsingMSWord
  • UsingMSExcel
  • UsingMSAccess

See Also