Microsoft Office Word and Python (Win XP)

Marco Nawijn nawijn at
Sat Jan 9 22:30:48 CET 2010

On Jan 9, 8:18 pm, "3lvss0... at" <3lvss0... at> wrote:
> Marco Nawijn: I have had installed pywin32 already. The three lines
> that you mentoined don't do this
I checked at my own computer and it works fine.
> also what did you mean with "doc =
> app.Documents.Open("c:\\example.doc")". Which document should I open
> with this line?
This was just meant as an example on how to open a Word document from
within python. This would be the basis for copying/appending from your
document to your target document (e.g. HD10.doc).
> It shouldn't be opened anything. I was asking about
> the script as automated process. If you know how could i do this?
Well it is a python script. So you can run it as an automated process.
You should just set app.Visible=False so the Word user interface
is not shown.

> Terry Reedy: I have never mentoined copying files but moving the whole
> text from, always the same (same name, same path), .doc file with.
> However copying (=moving) text to correct .doc file would be good yes.
> I know command prompt and its copy function but this way it wouldn't
> work because I would have to define the target file - the file INTO
> which I want to move the text. But I will never know the file name
> (target file). The only thing I know is:
> - the file is one of .doc files that start with "HD"
> - whole name of those .doc file is always HDX.doc where X is a number
> and I need to move the text into the file with maximum X (the most
> high number)
> - all the HD files will be always in the same path (same folder) but I
> would like to use the path inside the code (it might be obvious that I
> have to) because on PC and laptop, I have two different usernames and
> since HD files are located inside Documents And Settings, I have to
> use two copies of the script - one for PC, one for laptop.
> Dennis Lee Bieber: Im not familiar with python, also Im not
> programmer. Thats why Im not able to do so when people tell me "do
> this then use XYZ function which will give you ZYX from what you can
> do that and you will get result". Im still willing to learn but there
> are thousands of python tutorials and the one for exsactly this topic
> probably doesn't exsist. The .doc extension is required, so I cannot
> use .txt because I need the HD files in .doc.

More information about the Python-list mailing list