By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,929 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,929 IT Pros & Developers. It's quick & easy.

win32com.client.constants - AttributeError

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
how do I do this? Where is the Word object library?

Apr 21 '06 #3

P: n/a
Please help! Anyone else know?

Apr 21 '06 #4

P: n/a
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

P: n/a
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.