View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_6_] Otto Moehrbach[_6_] is offline
external usenet poster
 
Posts: 201
Default Copy/Paste to file of same name

Tom
Ron's idea is good for me. The sequence of tasks here is:
Loop through the files in the NEW folder. For each file:
Check if the file name is in the History folder.
If it isn't, copy the file to the History folder.
If it is, then using Ron's idea, change the name of the source file before
opening it.
Open the source & destination files.
Do the copying.
Save the destination file.
Close both and discard (kill) the source file.
Getting all the code right is what I'm working on now. Do you have an idea
of how to change the name of a closed file? Thanks for your help. Otto
"Tom Ogilvy" wrote in message
...
the only way to change the name of the file is to save it with a different
name (activeworkbook.SaveAs ) - so it is not easily discarded. You would
need to rename it again after you close the destination file.

--
Regards,
Tom Ogilvy


Otto Moehrbach wrote in message
...
Excel 2003
I'm helping an OP to automate a tiresome task of copying from file to

file,
over many, many files.
The problem I see is that the source and destination files have the
exact same name. In fact, that is the criteria by which the destination
file is selected. Since a file has to be open to copy from, and a file

has
to be open to paste to, how to get from here to there?
The only solution I can see at the moment is to use a dummy file in
between.
Now that I've written the above I see another way. Change the name of

the
source file (it will be discarded after the copy/paste).
Given that, what is the code to change the name of a file, given the

full
path is known.

Is there a better way? Thanks for your help. Otto