Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 58
Default VB file renaming.

I have a workbook that is an empty file when opened. I have a button on
worksheet 1 that when selected will import a csv file to a different
worksheet and then manipulate that date and then save it using a different
file name..
I want to check if the different file exists; if it does then I want to
purge a backup copy of the file that contains (old) as the last part of the
file name.
Next I want to rename the exist file (has not been opened) to the backup
file using the "(old") suffix to the name. I'm hoping theres a VB FILE
RENAME function that can be used to do this step.
Once the file is renamed then I want to save the opened file, where the
imported data is, to the name of the file that was prefiously renamed.
I use the KILL function to delete the old file but I can't figure out how to
rename the existing file as the backup file.

Any ideas would be greatly appreciated.

Thanks,

El Bee
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default VB file renaming.

The statement name you want is Name and it is coupled with an As keyword;
for example...

Name "c:\Temp\Temp.csv" As "c:\Temp\Temp(old).csv"

Note the use of the path with the file name... you can only leave it off if
you use ChDrive and ChDir to set the default path. Personally, I think it is
easier to just store the path in a variable and concatenate it onto your
file names in the two locations.

Rick



"El Bee" wrote in message
...
I have a workbook that is an empty file when opened. I have a button on
worksheet 1 that when selected will import a csv file to a different
worksheet and then manipulate that date and then save it using a different
file name..
I want to check if the different file exists; if it does then I want to
purge a backup copy of the file that contains (old) as the last part of
the
file name.
Next I want to rename the exist file (has not been opened) to the backup
file using the "(old") suffix to the name. I'm hoping theres a VB FILE
RENAME function that can be used to do this step.
Once the file is renamed then I want to save the opened file, where the
imported data is, to the name of the file that was prefiously renamed.
I use the KILL function to delete the old file but I can't figure out how
to
rename the existing file as the backup file.

Any ideas would be greatly appreciated.

Thanks,

El Bee


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 58
Default VB file renaming.

Rick,

That worked. I tried this before posting but after you replied I discovered
I mistyped one of the file names I used.
I hate it when I do that.

El Bee.



"Rick Rothstein (MVP - VB)" wrote:

The statement name you want is Name and it is coupled with an As keyword;
for example...

Name "c:\Temp\Temp.csv" As "c:\Temp\Temp(old).csv"

Note the use of the path with the file name... you can only leave it off if
you use ChDrive and ChDir to set the default path. Personally, I think it is
easier to just store the path in a variable and concatenate it onto your
file names in the two locations.

Rick



"El Bee" wrote in message
...
I have a workbook that is an empty file when opened. I have a button on
worksheet 1 that when selected will import a csv file to a different
worksheet and then manipulate that date and then save it using a different
file name..
I want to check if the different file exists; if it does then I want to
purge a backup copy of the file that contains (old) as the last part of
the
file name.
Next I want to rename the exist file (has not been opened) to the backup
file using the "(old") suffix to the name. I'm hoping theres a VB FILE
RENAME function that can be used to do this step.
Once the file is renamed then I want to save the opened file, where the
imported data is, to the name of the file that was prefiously renamed.
I use the KILL function to delete the old file but I can't figure out how
to
rename the existing file as the backup file.

Any ideas would be greatly appreciated.

Thanks,

El Bee



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming an excel file that is Linked. dls25 Excel Worksheet Functions 6 April 28th 23 03:42 AM
RENAMING WORKSHEETS LEOPARDSHIDEAWAY Excel Worksheet Functions 1 July 26th 07 10:27 PM
Renaming A File Rose Excel Discussion (Misc queries) 2 December 14th 06 05:33 PM
Renaming File Removes Worksheets Dustin D. Cook Excel Discussion (Misc queries) 2 April 7th 05 10:21 PM
Copying and renaming a file Craig Excel Discussion (Misc queries) 1 February 24th 05 10:47 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"