470,834 Members | 1,531 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,834 developers. It's quick & easy.

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 20026
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Oliver Emrich | last post: by
1 post views Thread by Justin Stockton | last post: by
reply views Thread by Paul McGuire | last post: by
reply views Thread by goermezer | last post: by
1 post views Thread by koia | last post: by
2 posts views Thread by cfriedalek | last post: by
1 post views Thread by Ransom | last post: by
11 posts views Thread by Bill Davy | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.