sign up for our newsletter

Course Objectives

Attendees completing this class should have a good working knowledge of the core Python language, be able to design and create Python objects, classes and modules, as well as have the ability to build a variety of tools and applications. Students will also be prepared to delve deeper into language fundamentals as well as tackle specific areas of application development taught in the following course, Advanced: Python Applications Programming.

‹‹ Back to class list


Programming Microsoft Office using Python

Like it or not, we live in a world where we will eventually have to interact with Win32 systems (if not already). It may be intermittent or something we have to deal with it on a daily basis, but regardless of how much exposure we face, the power of Python can be used to make our lives easier. Win32 COM is a service which allows applications to interact with each other. Specifically, Microsoft Office applications provide COM services, and COM client programs can be written to drive them. Traditionally, such clients are written in VB or (Visual) C++, two very powerful but very different tools.

Python is a systems application development language that is gaining popularity in a huge way. It is object-oriented, robust, agile, and easy-to-learn. It is as simple as VB but can do everything that C/C++, Java, Perl, PHP, and Ruby can do. For COM programming, Python is often viewed as a great substitute as it is more powerful than VB and is more expressive and less time-consuming than developing in C++.

The seminar exposes attendees to programming Win32 COM clients using Python. It is designed for both COM developers who want to learn how they can apply Python in their world and also for Python programmers who need to learn how to create COM clients. This is not a course in the fundamentals of COM: we will not be discussing the principles, concepts, and fundamentals of COM, philosophize on thoughts such as "Why COM?", nor we will not be learning about COM+, ATL, IDL, MFC, DCOM, ADO, etc.

Instead, we will immerse you in COM client programming by learning how to use Python to communicate with a variety of Microsoft applications, specifically Excel, Word, PowerPoint, and Outlook. We will have practical hands-on lab exercises where you will write small snippets of code that talk to and drive those applications. Time-permitting, we will also explore programming OpenOffice2, specifically running it in "server mode", and how to use (Star) writer to convert documents, e.g., Word to PDF.

Students completing this course should have a solid understanding of what COM client programming with Python is all about as well as being able to create simple scripts to drive the most well-known Microsoft Office applications. Specific topics include:

  • Introduction to Win32 COM
  • COM servers and clients
  • Language Introduction
  • How to write COM clients in Python
  • Programming Microsoft Word
  • Programming Microsoft Excel
  • Programming Microsoft PowerPoint
  • Programming Microsoft Outlook

Prerequisite: Attendees should be technical professionals somewhat familiar with Python. COM programming experience and a basic understanding of the Win32 architecture are not necessary but may be helpful. We especially welcome those coming from Unix-oriented environments (Linux, MacOS X, Solaris, *BSD, etc.) who are not familiar with Win32 programming but want to add it to their toolbox or need to learn it for their profession. . Additional reading such as the Python Tutorial and Python Library Reference are available from the Python website.

Required Software: A Python interpreter is required for this course as well as the Python for Windows Extensions. Both of these can be downloaded at the Core Python Programming website. You must also have a 32-bit Microsoft operating system as well as Microsoft Office applications: Word, Excel, PowerPoint, and Outlook.

Required Hardware: A laptop/notebook or otherwise portable computer is required for the course exercises. Attendees may use any Win32 platform where the above software is available. Bring your power cord!

‹‹ Back to class list