Connect to VBA Objects?

Bob Gailer bgailer at alum.rpi.edu
Mon Sep 22 21:59:16 EDT 2003


At 07:38 PM 9/22/2003, Kenneth Hutson wrote:

>Hi,
>I wonder if Python can connect to the object models exposed by Excel or Word.

Use Mark Hammond's win32all. 
http://starship.python.net/crew/mhammond/win32/Downloads.html

import win32com.client
app = win32com.client.Dispatch("word.application")
app.visible = 1
documents = self.app.Documents
doc = documents.Add("c:\\foo.doc")

etc.

app = win32com.client.Dispatch("excel.application")
app.visible = 1
app.WorkBooks.Open("c:\\foo.xls")

etc.

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003


More information about the Python-list mailing list