473,889 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2846
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.super news.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.Docume nts
doc = documents.Add(" c:\\foo.doc")

etc.

app = win32com.client .Dispatch("exce l.application")
app.visible = 1
app.WorkBooks.O pen("c:\\foo.xl s")

etc.

Bob Gailer
bg*****@alum.rp i.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
8802
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 codes, red some books but i still can't connect to a SQL server and edit the data.
11
27286
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 ODBC-driver (v8.00.04.08) but with no result. I've also tried a DSN-less connection. From VB.NET i'm using oleDbConnection to create the connection. If I don't supply a provider in the connection string, the program hangs saying that a provider is...
7
1517
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 to connect, but eventually got it working by setting (in the web.config file) the authentication mode to "Windows" and the identity impersonate flag to "True". I have left the identity username blank so that it picks up the username and password...
4
3811
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 because access ... well I just do! I was wondering if anybody knows of any 3rd party tools or com objects etc that would enable me to make this life giving connection? Thanks
2
2352
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 reconnect or change the connection via vba code, now I want to prohibit Access to start a connection on startup as this takes too much time. Thanks in advance!
8
25627
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 make connection, ORA-12154: TNS:could not resolve the connect identifier specified'. This error occurs in the applications global.asa file where I'm trying to set up a connection pool: <object runat="Server" scope="Application" id="oSession"...
2
9395
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 have installed IIS as my server. I have installed Mysql 5.0 and mysql ODBC driver 3.51.12 in their default locations. Database is up and running okay, as I've been able to create databases and tables and access them via the command prompt and...
3
4797
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 results into another DB? I know from Wscripts and MS-Sql that you can build just two objects but I did not see something like that in REXX. Thanks in advance for your help
2
1879
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 servers in a drop down, select the db name, then show a list of all the jobs in the job agent and show the status of each job, (failed, running, succeeded, etc) and the last time the job ran and by who. is this possible to do and if so how can i...
0
1934
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 the exe.config file is deleted, than it works. The exe.config contains : <?xml version="1.0" encoding="utf-8" ?>
0
9962
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11198
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10889
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10442
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9609
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5829
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.