473,385 Members | 1,562 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,385 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 21778
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.