473,396 Members | 2,039 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,396 software developers and data experts.

win32com.client.constants - AttributeError

On my machine, this runs fine, but when I try to run it on someone
elses machine it blows up with an attribute error:

<code>
import win32com.client, pythoncom

pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMEN TTHREADED)
myWord = win32com.client.dynamic.Dispatch ("Word.Application")
myWord.Visible = True
myDoc = myWord.Documents.Open(FileName= "C:\Test.doc")
myDoc .SaveAs(FileName = "c:\Test.htm", FileFormat =
win32com.client.constants.wdFormatHTML)

myDoc.Saved=1
myWord.Quit ()

del myWord
pythoncom.CoUninitialize()
</code>

It's pretty simple code so I don't understand why it doesn't work. I
verified that he has the same pywin32 module as me (build 207) and the
same python version (2.4.2).

Any ideas?

Apr 20 '06 #1
5 21789
The constants are only available if you've run makepy on the
Word object library.

Roger

"kbperry" <ke***********@gmail.com> wrote in message news:11*********************@e56g2000cwe.googlegro ups.com...
On my machine, this runs fine, but when I try to run it on someone
elses machine it blows up with an attribute error:

<code>
import win32com.client, pythoncom

pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMEN TTHREADED)
myWord = win32com.client.dynamic.Dispatch ("Word.Application")
myWord.Visible = True
myDoc = myWord.Documents.Open(FileName= "C:\Test.doc")
myDoc .SaveAs(FileName = "c:\Test.htm", FileFormat =
win32com.client.constants.wdFormatHTML)

myDoc.Saved=1
myWord.Quit ()

del myWord
pythoncom.CoUninitialize()
</code>

It's pretty simple code so I don't understand why it doesn't work. I
verified that he has the same pywin32 module as me (build 207) and the
same python version (2.4.2).

Any ideas?



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Apr 21 '06 #2
how do I do this? Where is the Word object library?

Apr 21 '06 #3
Please help! Anyone else know?

Apr 21 '06 #4
There are a couple of different ways to run makepy.
Start Pythonwin, and from the menu select
Tools->Com Makepy Utility. You should see a list
of registered typelibs. Select "Microsoft Word x.y
Object Library" and hit Ok.
This can also be done programatically by initiating
Word with
win32com.client.gencache.EnsureDispatch('Word.Appl ication')

Roger

"kbperry" <ke***********@gmail.com> wrote in message news:11**********************@g10g2000cwb.googlegr oups.com...
how do I do this? Where is the Word object library?


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Apr 21 '06 #5
Wow..I didn't even realize that this existed. Thanks for your help!

Apr 21 '06 #6

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

Similar topics

0
by: Oliver Emrich | last post by:
p {margin: 0px} Hi all, &nbsp;
1
by: Justin Stockton | last post by:
I recently upgraded from ActivePython 2.2.2 to ActivePython 2.3.2 and I'm running into an issue importing the win32com.client module. Before installing the new version, I made sure to properly...
0
by: Paul McGuire | last post by:
Software versions: Python - 2.3.3 win32all extensions - build 163 OS- Win2000 SP4 I am having trouble in accessing a customer's proprietary COM type library. After running makepy against the...
0
by: goermezer | last post by:
Hello, I have some problems to automate a CAD (computer aided design) Software called CATIA V5 from Dassault Systemes. CATIA V5 has a builtin VB-Editor like Word, Excel, … and registers itself...
1
by: koia | last post by:
Hi, I have a problem with adding attributes to a Line in an Excel drawing using the Python win32com interface. From recording in Excel I get the Macro: Sub Makro1()...
2
by: cfriedalek | last post by:
I'm driving Excel from python, largely successfully. Now I'm trying to add errorbars to XY scatter plots. Keep getting a com_error. Can't track down the problem. I modified a simple example to...
1
by: Ransom | last post by:
Hey folks... Newbie here. I'm working with win32com launching, closing and re-launching Excel grabbing output and doing stuff. Well, on some occasions, I get the following error: ...
4
by: rc | last post by:
I'm trying to convert VB code that registers COM+ components to Python. However, I'm unable to set values on COMAdminCatalogObject using the Value() method, it seems to think I'm trying to call the...
11
by: Bill Davy | last post by:
I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code which...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.