473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Connect to VBA Objects?

Hi,
I wonder if Python can connect to the object models exposed by Excel or
Word.
Thanks in advance,
Ken Hutson
San Antonio, Texas
Jul 18 '05 #1
4 2832
On Monday 22 September 2003 07:38 pm, Kenneth Hutson wrote:
Hi,
I wonder if Python can connect to the object models exposed by Excel or
Word.
Thanks in advance,
Ken Hutson
San Antonio, Texas


Yep, assuming you have the win32all extensions installed:

from win32com.client import Dispatch
d = Dispatch('Word.Application')
d.Visible = 1
....

-Dave

Jul 18 '05 #2
Kenneth Hutson wrote:

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


Yes it can, using the win32all extensions by Mark Hammond. Check the
archives for various examples, or consider buying the book on the subject:
http://www.amazon.com/exec/obidos/tg...glance&s=books

-Peter
Jul 18 '05 #3
Many thanks to Bob Gailer, Dave Brueck and Peter Hansen.
Kenneth Hutson
San Antonio, Texas

"Kenneth Hutson" <hu*******@ev1.net> wrote in message
news:vm************@corp.supernews.com...
Hi,
I wonder if Python can connect to the object models exposed by Excel or
Word.
Thanks in advance,
Ken Hutson
San Antonio, Texas

Jul 18 '05 #4
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/mham...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
bg*****@alum.rpi.edu
303 442 2625
---
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

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: T. Wintershoven | last post by:
Hello, Although i write programs in VB for a while now, i've allways used the datacontrol and MS-Access DBs for data storage and never (and i mean never) used SQL. I lookt in many sample...
11
by: Marcus | last post by:
Hello! I'm trying to write a VB.NET program that connects to a AS/400 Server. I've tried almost everything, but it will not connect. I've tried to set up a DSN using the Client Access...
7
by: Oenone | last post by:
Sorry for the cross-post but I've really no idea where this is best suited. I've an ADO.NET application which connects to a SQL Server database. I have spent the entire morning trying to get it...
4
by: Frank | last post by:
Hi I am a poor student studying towards my MCSD. I have managed to get a cheapish student version of vb.net. Problem is that this version does not connect to sql databases and I need it to...
2
by: Cornelius.Eckhoff | last post by:
Hello, I just want my ADP not to connect on startup. Normally when opening the xx.adp-file Access tries to connect automatically. Is there any option, trick, workaround? I found a source to...
8
by: CJM | last post by:
I have a working web application (ASP) which links to an Oracle 10g DB via OO4O. I'm trying to port it to either of two test servers, but in fact, I can't get it to work with either - 'Unable to...
2
by: 111mike | last post by:
Hello, Here's my problem. I cannot connect to mysql database using odbc string connections or dns. I keep getting a "cannot connect to mysql server localhost." I'm running windows XP Pro and...
3
by: cberthu | last post by:
Hi all, Is it possible to have two connects in the same rexx script to different DB's? I have to get data form on DB (with specifics selects and filter out some values with RExx) and save the...
2
by: Steve | last post by:
Is there a way to connect to SQL server and read all of the jobs listed in the job agent and get the status of each job? I want to create either a web page or a winForm, have a list of all SQL DB...
0
by: =?Utf-8?B?dG9t?= | last post by:
Hi, I have a .net 2.0 windows client that connects to webservices. In most cases it works fine. However I have one client that gets 'Unable to connect to the remote server'. If on that client...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.