win32com.client.constants - AttributeError

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kbperry

    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.CoIni tializeEx(pytho ncom.COINIT_APA RTMENTTHREADED)
    myWord = win32com.client .dynamic.Dispat ch ("Word.Applicat ion")
    myWord.Visible = True
    myDoc = myWord.Document s.Open(FileName = "C:\Test.do c")
    myDoc .SaveAs(FileNam e = "c:\Test.ht m", FileFormat =
    win32com.client .constants.wdFo rmatHTML)

    myDoc.Saved=1
    myWord.Quit ()

    del myWord
    pythoncom.CoUni nitialize()
    </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?

  • Roger Upole

    #2
    Re: win32com.client .constants - AttributeError

    The constants are only available if you've run makepy on the
    Word object library.

    Roger

    "kbperry" <keith.b.perry@ gmail.com> wrote in message news:1145565829 .143096.75510@e 56g2000cwe.goog legroups.com...[color=blue]
    > 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.CoIni tializeEx(pytho ncom.COINIT_APA RTMENTTHREADED)
    > myWord = win32com.client .dynamic.Dispat ch ("Word.Applicat ion")
    > myWord.Visible = True
    > myDoc = myWord.Document s.Open(FileName = "C:\Test.do c")
    > myDoc .SaveAs(FileNam e = "c:\Test.ht m", FileFormat =
    > win32com.client .constants.wdFo rmatHTML)
    >
    > myDoc.Saved=1
    > myWord.Quit ()
    >
    > del myWord
    > pythoncom.CoUni nitialize()
    > </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?
    >[/color]




    ----== 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 =---

    Comment

    • kbperry

      #3
      Re: win32com.client .constants - AttributeError

      how do I do this? Where is the Word object library?

      Comment

      • kbperry

        #4
        Re: win32com.client .constants - AttributeError

        Please help! Anyone else know?

        Comment

        • Roger Upole

          #5
          Re: win32com.client .constants - AttributeError

          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.Ensur eDispatch('Word .Application')

          Roger

          "kbperry" <keith.b.perry@ gmail.com> wrote in message news:1145631219 .159431.105040@ g10g2000cwb.goo glegroups.com.. .[color=blue]
          > how do I do this? Where is the Word object library?
          >[/color]



          ----== 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 =----

          Comment

          • kbperry

            #6
            Re: win32com.client .constants - AttributeError

            Wow..I didn't even realize that this existed. Thanks for your help!

            Comment

            Working...