Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
changing the name of the closed file is Ron's idea.
Name statement Renames a disk file, directory, or folder. -- Regards, Tom Ogilvy Otto Moehrbach wrote in message ... 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom. Otto
"Tom Ogilvy" wrote in message ... changing the name of the closed file is Ron's idea. Name statement Renames a disk file, directory, or folder. -- Regards, Tom Ogilvy Otto Moehrbach wrote in message ... 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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Otto
You can use this rename the file in the New folder before you open it Nname is the full path to the file in the New folder Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Did you mistype something there? Nname is not in the code you wrote.
Thanks for your help. Otto "Ron de Bruin" wrote in message ... Hi Otto You can use this rename the file in the New folder before you open it Nname is the full path to the file in the New folder Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "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 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Name oldpathname As newpathname
must be done before you open the file. Regards, Tom Ogilvy Otto Moehrbach wrote in message ... Did you mistype something there? Nname is not in the code you wrote. Thanks for your help. Otto "Ron de Bruin" wrote in message ... Hi Otto You can use this rename the file in the New folder before you open it Nname is the full path to the file in the New folder Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "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 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom. That's clear. Otto
"Tom Ogilvy" wrote in message ... Name oldpathname As newpathname must be done before you open the file. Regards, Tom Ogilvy Otto Moehrbach wrote in message ... Did you mistype something there? Nname is not in the code you wrote. Thanks for your help. Otto "Ron de Bruin" wrote in message ... Hi Otto You can use this rename the file in the New folder before you open it Nname is the full path to the file in the New folder Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "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 |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It is a example
I don't see you code so I can't use your code Dim NewN As String MyPath2 = "C:\New" If the file exist in both folders you can use this NewN = MyPath2 & "\" & FNames Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" FNames is the filename that you can use if use the Dir function to loop through all your files for a example see this page http://www.rondebruin.nl/copy3.htm -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Otto Moehrbach" wrote in message ... Did you mistype something there? Nname is not in the code you wrote. Thanks for your help. Otto "Ron de Bruin" wrote in message ... Hi Otto You can use this rename the file in the New folder before you open it Nname is the full path to the file in the New folder Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "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 |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ron
That site is a gold mine. Thanks. Otto "Ron de Bruin" wrote in message ... It is a example I don't see you code so I can't use your code Dim NewN As String MyPath2 = "C:\New" If the file exist in both folders you can use this NewN = MyPath2 & "\" & FNames Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" FNames is the filename that you can use if use the Dir function to loop through all your files for a example see this page http://www.rondebruin.nl/copy3.htm -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Otto Moehrbach" wrote in message ... Did you mistype something there? Nname is not in the code you wrote. Thanks for your help. Otto "Ron de Bruin" wrote in message ... Hi Otto You can use this rename the file in the New folder before you open it Nname is the full path to the file in the New folder Name NewN As Left(NewN, Len(NewN) - 4) & "something.xls" -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "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 |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hmmm. I would read the New folder first, check if that name exists in history, if not, move it over there, if so, copy the rows from the new folder workbook you need, close that workbook, keep the contents of the clipboard, open the one in history, paste it and so on. Seems like that would work.
|
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Slark
I'll give that a shot. Excel has such a propensity to clear the clipboard that I just dismissed that idea. But maybe it will work. Thanks. Otto "slark" wrote in message ... Hmmm. I would read the New folder first, check if that name exists in history, if not, move it over there, if so, copy the rows from the new folder workbook you need, close that workbook, keep the contents of the clipboard, open the one in history, paste it and so on. Seems like that would work. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy, paste without file name referenced after paste | Excel Discussion (Misc queries) | |||
Protecting a file from Copy/Paste | Excel Discussion (Misc queries) | |||
How can I allow only copy of a file not cut and paste? | Excel Discussion (Misc queries) | |||
copy/paste from one file to another without file name reference | Excel Discussion (Misc queries) | |||
copy, paste and save file | Excel Programming |