Version 20 of COM

Updated 2002-10-30 12:39:30

Microsoft's Component Object Model [L1 ] ...


tcom offers both client and server COM functionality.

This is also included in recent ActiveTcl releases.


optcl ...


TclScript also is COM-aware.


TCLBridge allows Tcl to call COM objects and vice-versa. Very powerful, lots of options.


COSH ...


Many popular Windows applications expose a COM automation [L2 ] interface, which allows external programs to launch and control them. The starting point to an application's COM automation interface is through its programmatic identifier (ProgID). Here are a few example ProgID's, any of which might be used in, for instance, tcom with

    set application [::tcom::ref createobject $ProgID]


    Netscape.Network.1 [http://developer.netscape.com/docs/manuals/communicator/OLE/ole2net.htm]
    FrontPage.Editor.Document
    Word.Document (note that WordPad is ''not'' a COM server)
    InternetExplorer.Application
    Excel.Application
    Excel.Application.8
    PDF.PdfCtrl.1
    Word.Application
    DSOleFile.PropertyReader








How one discovers the API for a COM-exporting application of interest.

How does one discover the API for a COM-exporting application of interest? One place to start is by Googling "$app_name object model". The (full) help for most Microsoft applications includes this information, often disguised as instructions on use of Visual Basic for Applications or VBScript. These reference guides usually are not installed by default during the typical installation. They can be added later by rerunning the setup program with the custom install option. Also, one can often start the application in question, and select Tools/Macros/Visual Basic Editor, then View/$app Explorer, and the API should be within a click or two more.

You can also record a macro and then examine the code.

To record a macro

Use the following steps to record a macro:

  • On the Tools menu, point to Macro and click Record New Macro.
  • Type a name for the new macro in the Macro name box and click OK.
  • Perform the actions you want to learn more about.
  • When you have completed the actions you want to record, on the Stop Recording toolbar click Stop Recording.

To view a recorded macro

Use the following steps to view a recorded macro:

  • On the Tools menu, point to Macro and click Macros .
  • Find and click to select your recorded macro in the list of available macros.
  • Click Edit.

How to Obtain Built-In Constant Values for an Office Application

The article http://support.microsoft.com/support/kb/articles/Q239/9/30.ASP describes how to obtain the constant values for Office applications from type library files. Here's an example of how to do it in Tcl.

Load the tcom extension.

    % package require tcom
    3.8

Read the type library file.

    % ::tcom::import $pathToOfficeDirectory/excel9.olb
    Excel

The ::tcom::import command put the constant values into some arrays. It returns the namespace where it created the arrays.

    % info vars ::Excel::*
    (many array names listed)
    % parray ::Excel::XlRowCol
    ::Excel::XlRowCol(xlColumns) = 2
    ::Excel::XlRowCol(xlRows)    = 1

[Explain relation between COM and WSH.]


Alex Martelli: "COM-related technologies seem mostly pretty good, except for the little detail that they're often huge, rambling, and full of redundancies and pitfalls -- this goes for the object model of WMI just as well as for those of MS Office applications."


Category Acronym