Re: [python-win32] py2.7 and multiple DDE servers on Win32, possible?

2011-06-15 Thread Mark Hammond
On 11/06/2011 3:19 AM, RayS wrote: Hello I know that the default behavior since 2.? has been only one DDE server allowed. Is it possible to back-hack this restriction? It is possible, yeah - it's just a matter of someone doing it :) Cheers, Mark __

Re: [python-win32] py2.7 and multiple DDE servers on Win32, possible?

2011-06-15 Thread Mark Hammond
On 15/06/2011 8:15 PM, Mark Hammond wrote: On 11/06/2011 3:19 AM, RayS wrote: Hello I know that the default behavior since 2.? has been only one DDE server allowed. Is it possible to back-hack this restriction? It is possible, yeah - it's just a matter of someone doing it :) Oops - sorry -

Re: [python-win32] Creating PyCComboBox?

2011-06-15 Thread Mark Hammond
On 11/06/2011 4:55 PM, Greg Ewing wrote: How are you supposed to create a PyCComboBox? There doesn't seem to be a CreateComboBox function anywhere. I tried using CreateControl("COMBOBOX", ...) but it says that the CLSID is invalid. I think you just want a CreateWindow(Ex) with "Combobox" as th

Re: [python-win32] Telit PhytonWin

2011-06-15 Thread Mark Hammond
On 13/06/2011 10:00 PM, Famacoin wrote: Hi We have a problem loading script for the GM862-GPS module over 7k when we try to load gives ERROR IN THE DOWNLOAD, and sometimes says OK but does not load the entire file, we have checked the serial port but do not get the fault?. I'm afraid I have no

Re: [python-win32] Converting HTML formatting to Microsoft Word

2011-06-15 Thread Mark Hammond
On 14/06/2011 6:51 PM, sharpblade wrote: I whipped up this function: http://pastebin.com/kaZz5dBd which should work, but line 22 and 23 doesn't work for some reason - all text after it is bold. The last thing you do in those lines is set the range to bold - presumably later you then insert mor

Re: [python-win32] Converting HTML formatting to Microsoft Word

2011-06-15 Thread sharpblade
Heh, thanks! I dreamed of writing some nice recursive function, but I gave up and moved to the HTMLParser module: http://paste.pocoo.org/show/408125/ Its WIP at the moment but works nicely with bold, underline, italics and bulletpoint lists. It was a lot nicer and more concise before I found out t

[python-win32] Generic/simple way to make backups of objects/their states?

2011-06-15 Thread Jacob Kruger
I know I can do a version of manual import/export process to do something like either backup all relevant attributes of some or other object to something like a CSV, or XML string rendition, and then save that to a file easily enough, but just wondering if there's any simpler way to render an ob

Re: [python-win32] Generic/simple way to make backups of objects/their states?

2011-06-15 Thread Tim Golden
On 15/06/2011 13:51, Jacob Kruger wrote: I know I can do a version of manual import/export process to do something like either backup all relevant attributes of some or other object to something like a CSV, or XML string rendition, and then save that to a file easily enough, but just wondering if

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tom Hawkins
By 'manually' I mean choosing the File->Save As menu item and changing 'Save as type' to Plain Text. I'm not familiar with how to automate it directly from Python, but in Word VBA you would use something like: ActiveDocument.SaveAs FileName:="myfile.txt", FileFormat:=wdFormatText

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread cool_go_blue
Thanks. I clicked on the following link and I get lost about how to find APIs. I think I need to go to the following page: http://msdn.microsoft.com/en-us/library/bb225019%28v=office.12%29.aspx to find APIs. To read an auto-number paragraph, I check: word Document Object Map and find paragraph.

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tim Golden
On 15/06/2011 15:30, Tom Hawkins wrote: By ‘manually’ I mean choosing the File->Save As menu item and changing ‘Save as type’ to Plain Text. I’m not familiar with how to automate it directly from Python, but in Word VBA you would use something like: ActiveDocument.SaveAs FileName:="myfile.txt",

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread cool_go_blue
I did try the one you suggest. But I got:   File "D:\projects\Myself\MySVD\src\ReadWord.py", line 11, in     app.ActiveDocument.SaveAs('D:\projects\Myself\HelloPython\src\Drugreservoir1.txt',FileFormat=win32com.client.constants.wdFormatText)   File "D:\Softwares\Python27\lib\site-packages\win32c

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tim Roberts
cool_go_blue wrote: > I did try the one you suggest. But I got: > > File "D:\projects\Myself\MySVD\src\ReadWord.py", line 11, in > > app.ActiveDocument.SaveAs('D:\projects\Myself\HelloPython\src\Drugreservoir1.txt',FileFormat=win32com.client.constants.wdFormatText) > File > "D:\Softwares\P

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tim Roberts
cool_go_blue wrote: > this is the first three lines of my code: > > app = win32com.client.Dispatch('Word.Application') > app.Documents.Open('D:\projects\Myself\HelloPython\src\Drugreservoir.doc') > app.ActiveDocument.SaveAs('D:\projects\Myself\HelloPython\src\Drugreservoir1.txt',FileFormat=win32com

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread cool_go_blue
Thank you so much. It works. But where can I find the APIs such as Dispatch vs gencache.EnsureDispatch? Now, I have another problem. Using the auto save, all auto-numbers before paragraphs are not read by the following code: for word in doc.Content.Text.encode("cp1252", "replace").split():     p

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tim Roberts
cool_go_blue wrote: > Thank you so much. It works. But where can I find the APIs such as > Dispatch vs gencache.EnsureDispatch? > To a certain extent, this comes from on-the-job experience. It is described in the win32com documentation. There's also a couple of books on Python in Windows ("Pytho

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread cool_go_blue
So, my following code: app = win32com.client.gencache.EnsureDispatch('Word.Application') app.Documents.Open(r'D:/projects/Myself/HelloPython/src/Drugreservoir.doc') app.ActiveDocument.SaveAs(r'D:/projects/Myself/HelloPython/src/Drugreservoir1.txt',FileFormat=win32com.client.constants.wdFormatText)

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tim Roberts
cool_go_blue wrote: > So, my following code: > > app = win32com.client.gencache.EnsureDispatch('Word.Application') > app.Documents.Open(r'D:/projects/Myself/HelloPython/src/Drugreservoir.doc') > app.ActiveDocument.SaveAs(r'D:/projects/Myself/HelloPython/src/Drugreservoir1.txt',FileFormat=win32com.c

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread cool_go_blue
THanks. After replying to your email, I thought about what you wrote, just like what you said in the following email. So, for a normal text file, just use open to read the file. There is no need to use the way to open a word document via win32com to read a text file. Will win32com consume more t

Re: [python-win32] Creating PyCComboBox?

2011-06-15 Thread Greg Ewing
Mark Hammond wrote: I think you just want a CreateWindow(Ex) with "Combobox" as the class. Yes, but the puzzle was how to get a PyCComboBox object rather than a raw window handle. I discovered it can be done by calling CreateWindowFromHandle on the resulting handle, but I don't think I should

Re: [python-win32] UnicodeEncodingError when print a doc file

2011-06-15 Thread Tim Roberts
cool_go_blue wrote: > THanks. After replying to your email, I thought about what you wrote, > just like what you said in the following email. So, for a normal text > file, just use open to read the file. There is no need to use the way > to open a word document via win32com to read a text file. Wil