Skip to content

Naming Clashes

The COM object's type library determines the class names that are assigned by the class generator when you import a COM object. Unfortunately, there is always the possibility that two different COM objects might define the same class name.

If you try to import two such COM objects and use them in one application, you will encounter a class-name clash, i.e., two class definitions with the same class name.

A common example of this problem is when you import the MSWord and MSExcel Automation libraries. Both libraries would generate the following classes:

  • cComApplication
  • cComDocument
  • cComWindows
  • cComRecentFiles
  • cComFont

The recommended way to deal with this problem is to prefix each class name with the name of the package it is defined in.

For example, if you import the MSWord 8 Automation library, you would edit the class names as follows:

  • cComApplication becomes cComMSWord8_Application
  • cComDocument becomes cComMSWord8_Document
  • cComWindows becomes cComMSWord8_Windows

See Also

Common Problems