This article shows you how to call COM components from Python, and shows you how to use COM extensions to access the mail merge functionalities of MS Word in Python.
Generally system programming is considered to be the domain of compiled languages, especially when the system under consideration is MS Windows. However there are always exceptions to the general rule. When the scripting language in consideration is of the caliber of Python, the exception is more profound.
Python gets its caliber from the fact that for each platform there is a specific set of extensions, using which the full potential of the host system can be completely tapped into. Also there are no "semantics" or syntactic changes required when using these extensions. Thus the developer can avail himself of the power of the native APIs without leaving the highly flexible environment of Python.
The extension to the Windows platform contains three distinct sets of extensions -- the COM extension, access to the native Win32 API, and the PythonWin GUI extensions. In this article, I will be discussing the COM extensions. The first section will provide an overview of the COM technology. The focus of the second section will be the steps involved in using the COM extensions. In the third segment, I will be using the COM extensions to access the mail merge functionalities of MS Word. That is the outline for this discussion.