9 Replies - 41659 Views - Last Post: 16 February 2011 - 08:00 AM Rate Topic: -----

#1 wisam abbasi  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 12-December 09

win32com.client library

Posted 15 February 2011 - 11:44 AM

I'm trying to install the win32com.client library for Python 2.7.1 to open Microsoft word files .But all I've found doesn't work or gives an error . Please help.

The error is as follow:
Traceback (most recent call last):
  File "C:\Users\one.omary\Desktop\word.py", line 5, in <module>
    from win32com.client import Dispatch             # early or late binding
ImportError: No module named win32com.client



Is This A Good Question/Topic? 0
  • +

Replies To: win32com.client library

#2 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: win32com.client library

Posted 15 February 2011 - 11:52 AM

Do you think Python for Windows would work?
Was This Post Helpful? 0
  • +
  • -

#3 wisam abbasi  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 12-December 09

Re: win32com.client library

Posted 15 February 2011 - 12:04 PM

I am downloading it now. I've seen it but I am not sure, I'll try it now . Thanks
Was This Post Helpful? 0
  • +
  • -

#4 wisam abbasi  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 12-December 09

Re: win32com.client library

Posted 15 February 2011 - 12:23 PM

Oh, it gives me the same error :online2long:
Was This Post Helpful? 0
  • +
  • -

#5 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: win32com.client library

Posted 15 February 2011 - 12:27 PM

Try importing pywin32
Was This Post Helpful? 0
  • +
  • -

#6 wisam abbasi  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 12-December 09

Re: win32com.client library

Posted 15 February 2011 - 12:40 PM

I've executed the setup file and it did not work, and I've added pywin32 to the lib folder in the python folder and it did not work either.

Traceback (most recent call last):
  File "C:\Users\one.omary\Desktop\word.py", line 1, in <module>
    import pywin32
ImportError: No module named pywin32


Was This Post Helpful? 0
  • +
  • -

#7 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: win32com.client library

Posted 15 February 2011 - 12:42 PM

Hmmm... I think I'd have to walk in your shoes a little to figure this one out. Unfortunately, that's easier said than done while I'm at work... and I'm taking another member of DIC out to dinner tonight, so I might not be able to do more until tomorrow... Motoma, where are you?!?!
Was This Post Helpful? 0
  • +
  • -

#8 wisam abbasi  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 12-December 09

Re: win32com.client library

Posted 15 February 2011 - 12:54 PM

No problem, you've done your best.
Thanks alot.
:bigsmile:
Was This Post Helpful? 0
  • +
  • -

#9 wisam abbasi  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 72
  • Joined: 12-December 09

Re: win32com.client library

Posted 16 February 2011 - 07:44 AM

Hi, I've found the solution to y problem by downloading the pywin32 librare from this link
http://www.lfd.uci.e...lke/pythonlibs/

and here is the code:
from sys import argv
docdir = 'C:\\'
if len(argv) == 2: docdir = argv[1]              # ex: comclient.py a:\

from win32com.client import Dispatch             # early or late binding
word  = Dispatch('Word.Application')             # connect/start Word
word.Visible = 1                                 # else Word runs hidden

# create and save new doc file
newdoc = word.Documents.Add( )                       # call Word methods
spot   = newdoc.Range(0,0)
spot.InsertBefore('Hello COM client world!')     # insert some text
newdoc.SaveAs(docdir + 'pycom.doc')              # save in doc file
newdoc.SaveAs(docdir + 'copy.doc')
newdoc.Close( )

# open and change a doc file
olddoc = word.Documents.Open(docdir + 'samples.docx')
finder = word.Selection.Find
finder.text = 'COM'
finder.Execute( )
word.Selection.TypeText('Automation')
olddoc.Close( )



Thanks
Was This Post Helpful? 1
  • +
  • -

#10 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 828
  • View blog
  • Posts: 2,235
  • Joined: 23-December 08

Re: win32com.client library

Posted 16 February 2011 - 08:00 AM

Thank you very much for posting your solution :) Now we don't have to keep workin on it, and googlers with similar problems will find their solution.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1