472,330 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 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 2778
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.