Microsoft Office Word and Python (Win XP)

2010-01-09 Thread 3lvss0...@gmail.com
Hi.
Im very new with python. I have got some answer on my issue to use
interop or COM ''plugins'' to access MS Word through python but i
don't even know what those two ''plugins'' are so I cannot use them.
What I want to do is the following:

I need the script that moves (only moves, not change or delete!)
entire (100% of the text) text from one .doc file to another. But its
not so easy as it sounds. The target .doc file is not the only one but
can be many of them. All the target .doc files are always in the same
folder (same path) but all of them don't have the same name. The .doc
file FROM where I want to move entire text is only one, always in the
same folder (same path) and always with the same file name.
Names of the target are only similar but as I have said before, not
the same. Here is the point of whole script:
Target .doc files have the names:
HD1.doc
HD2.doc
HD3.doc
HD4.doc
and so on

What I would like to have is moved the entire (but really all of the
text, must be 100% all) text into the .doc file with the highest ( ! )
number. The target .doc files will always start with ''HD'' and always
be similar to above examples.
It is possible that the doc file (target file) is only one, so only
HD1.doc. Therefore ''1'' is the maximum number and the text is moved
into this file.
Sometimes the target file is empty but usually won't be. If it won't
be then the text should be moved to the end of the text, into first
new line (no empty lines inbetween).
So for example in the target file which has the maximum number in its
name is the following text:

a
b
c

In the file from which I want to move the text is:

d

This means I need in the target file this:

a
b
c
d

Could someone tell me please how to do this?

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Office Word and Python (Win XP)

2010-01-09 Thread 3lvss0...@gmail.com
Marco Nawijn: I have had installed pywin32 already. The three lines
that you mentoined don't do this, also what did you mean with "doc =
app.Documents.Open("c:\\example.doc")". Which document should I open
with this line? It shouldn't be opened anything. I was asking about
the script as automated process. If you know how could i do this?

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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Office Word and Python (Win XP)

2010-01-09 Thread 3lvss0...@gmail.com
Marco did you also make the HD files to it worked for you? Because I
cannot even imagine how only three lines would do everything - find
correct folder (path) of the files, find maximum number, move the
entire text,... In this 3 lines is not stated that we are talking
about the files that start with "HD" so I wonder how it worked for
you. Nothing was moved on my PC. I have done some research about the
line "app = Dispatch("Word.Application")" and saw this:

http://www.programmingforums.org/post105986.html

The script described here is different comparing to what I want to do
but I might be able to use some ideas - of course, since Im not a
programmer, I need to study the functions before. On the link the user
is trying to replace parts (predefinited or not - i don't know) of
the .doc files - this is not moving/copying entire text but the topic
is still about writing something into .doc through python.
Unfortunatelly for me, his script doesn't need to search for
correct .doc file.

So I kept searching and came to this:

http://www.daniweb.com/forums/thread129924.html

This task is very close to what I want but still different. If we try
to compare;

"I am a text" (his task) = already exsisting (if any) text in my HDX
file where X is the highest number (my task)
"Hello" (his task) = whole text inside .doc with always the same name
on the same location (my task)

then thats it. I believe just those two differences exsist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Office Word and Python (Win XP)

2010-01-10 Thread 3lvss0...@gmail.com
so does anyone know how I could do this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Office Word and Python (Win XP)

2010-01-10 Thread 3lvss0...@gmail.com
?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Office Word and Python (Win XP)

2010-01-10 Thread 3lvss0...@gmail.com
no idea :-(
-- 
http://mail.python.org/mailman/listinfo/python-list