reading character in word

sebastien s.thuriez at quantaflow.com
Tue Dec 4 12:59:22 EST 2001


Hi,

Maybe have you encountered my problem : I do not manage to read
accentuated characters such as éèà ... from a microsoft word
application using win32com.client.
 
Here is the programm that I used :

from win32com.client import constants, Dispatch

word= Dispatch('Word.Application')
mondoc=word.Documents.Open(r"c:\test.doc")
nombre_caracteres=mondoc.Characters.Count
for numero_caractere in range (1,int(nombre_caracteres)+1):
    caractere=mondoc.Characters.Item(numero_caractere)
    try:
        print caractere
     except:
        print("cannot read character")
        pass


Everything is fine as soon as I do not use characters with coma accent
such as é à è in the document...


I also tried on my PC to do :

test_input=raw_input("entrer phrase avec accents : ")
print str(test_input)
for char in test_input:
    print char,ord(char) 
  
after enterring word using the éàè..there is no problem printing the
correct letters (for exemple été).

There maybe some option in Word that I should set ??

I hope that someone will have some leads ...

Sebastien.



More information about the Python-list mailing list