Does SaveAs save the doc to a txt file? What I was thinking is
app.Documents.Open('D:/projects/Myself/HelloPython/src/Drugreservoir1.
txt') can
open the txt file which I can read. Is there any way I can read the
saved txt file after
SaveAs...
Yes of course, you can use the ordinary Python file
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
. But what API should I use to read all words and the
auto-number of this paragraph. It seems a huge table in each object map. Thanks.
-- On Tue, 6/14/11, Preston Landers pland...@gmail.com wrote
From: Preston Landers pland...@gmail.com
Subject: Re: [python-win32] UnicodeEncodingError when print
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,
: [python-win32] UnicodeEncodingError when print a doc file
To:
Cc: python-win32@python.org
Date: Wednesday, June 15, 2011, 10:50 AM
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
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 module
app.ActiveDocument.SaveAs('D:\projects\Myself\HelloPython\src\Drugreservoir1.txt',FileFormat=win32com.client.constants.wdFormatText)
File
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')
/Drugreservoir1.txt')
can open the txt file which I can read. Is there any way I can read the saved
txt file after SaveAs...
--- On Wed, 6/15/11, Tim Roberts t...@probo.com wrote:
From: Tim Roberts t...@probo.com
Subject: Re: [python-win32] UnicodeEncodingError when print a doc file
To: Python-Win32
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')
time and memory to
read a text file than the general input stream? Thanks again.
--- On Wed, 6/15/11, Tim Roberts t...@probo.com wrote:
From: Tim Roberts t...@probo.com
Subject: Re: [python-win32] UnicodeEncodingError when print a doc file
To: Python-Win32 List python-win32@python.org
Date
I try to read a word document as follows:
app = win32com.client.Dispatch('Word.Application')
doc = app.Documents.Open('D:\myfile.doc')
print doc.Content.Text
I receive the following error:
raceback (most recent call last):
File D:\projects\Myself\MySVD\src\ReadWord.py,
to process words in
an open word document. Thanks.
--- On Tue, 6/14/11, Preston Landers pland...@gmail.com wrote:
From: Preston Landers pland...@gmail.com
Subject: Re: [python-win32] UnicodeEncodingError when print a doc file
To: cool_go_blue cool_go_b...@yahoo.com
Date: Tuesday, June 14, 2011, 12:37 PM
cool_go_blue wrote:
Thanks. It works. Actually, what I want to do is to parse the whole
document. How can I retrieve the list of words in the
document? I use the following code:
for word in doc.Content.Text.encode(cp1252, replace):
print word
It seems that word is each a character.
...@probo.com
Subject: Re: [python-win32] UnicodeEncodingError when print a doc file
To: python-win32@python.org python-win32@python.org
Date: Tuesday, June 14, 2011, 9:02 PM
cool_go_blue wrote:
Thanks. It works. Actually, what I want to do is to parse the whole
document. How can I retrieve the list
I think you'll have to get into the guts of the Document object to do things
like that. Here's the official Word 2007 object model documentation. Any
tutorials or examples you can find that use other languages like C# or
VB.NET would be relevant, you just have to translate them a bit to Python.
15 matches
Mail list logo