Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good morning guys,
does any one know how I can rename a file using VBA code. I display a file dialog box allowing the user to pick a .csv file. Because of the quirks of Excel I need that file to come in as a .Txt file. I do not want the user to have to rename the file as the existing .csv file is created by a third party program. My VBA macro then reads the .Csv file and does it's thing. I need it to be .Txt. How do I rename the file in the directory before I open it. Thanks for any help. Best Regards, Steve Wilson. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Name statement:
Dim OldName, NewName OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names. Name OldName As NewName ' Rename file. OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE" Name OldName As NewName ' Move and rename file. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Always Learning" <NoMoreSpam@MyEmail wrote in message ... Good morning guys, does any one know how I can rename a file using VBA code. I display a file dialog box allowing the user to pick a .csv file. Because of the quirks of Excel I need that file to come in as a .Txt file. I do not want the user to have to rename the file as the existing .csv file is created by a third party program. My VBA macro then reads the .Csv file and does it's thing. I need it to be .Txt. How do I rename the file in the directory before I open it. Thanks for any help. Best Regards, Steve Wilson. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Rob,
Fantastic. Works like a charm, Thank you. Is there a way that I can just copy the file rather than renaming and then deleting the file so I leave everything as it was? I appreciate your help. Best Regards, Steve Wilson. "Rob van Gelder" wrote in message ... Name statement: Dim OldName, NewName OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names. Name OldName As NewName ' Rename file. OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE" Name OldName As NewName ' Move and rename file. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Always Learning" <NoMoreSpam@MyEmail wrote in message ... Good morning guys, does any one know how I can rename a file using VBA code. I display a file dialog box allowing the user to pick a .csv file. Because of the quirks of Excel I need that file to come in as a .Txt file. I do not want the user to have to rename the file as the existing .csv file is created by a third party program. My VBA macro then reads the .Csv file and does it's thing. I need it to be .Txt. How do I rename the file in the directory before I open it. Thanks for any help. Best Regards, Steve Wilson. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just move it with the same name using the code provided.
OldName = "C:\MYDIR\OLDFILE.xls": NewName = "C:\YOURDIR\OLDFILE.xls" -- Regards, Tom Ogilvy "Always Learning" <NoMoreSpam@MyEmail wrote in message ... Hi Rob, Fantastic. Works like a charm, Thank you. Is there a way that I can just copy the file rather than renaming and then deleting the file so I leave everything as it was? I appreciate your help. Best Regards, Steve Wilson. "Rob van Gelder" wrote in message ... Name statement: Dim OldName, NewName OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names. Name OldName As NewName ' Rename file. OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE" Name OldName As NewName ' Move and rename file. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Always Learning" <NoMoreSpam@MyEmail wrote in message ... Good morning guys, does any one know how I can rename a file using VBA code. I display a file dialog box allowing the user to pick a .csv file. Because of the quirks of Excel I need that file to come in as a .Txt file. I do not want the user to have to rename the file as the existing .csv file is created by a third party program. My VBA macro then reads the .Csv file and does it's thing. I need it to be .Txt. How do I rename the file in the directory before I open it. Thanks for any help. Best Regards, Steve Wilson. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
Thanks for taking the time to respond. Your answer is so simple and obvious I want to know why didn't I think of that? I am always trying to think of the big answer when there is an obvious one. Best Regards, Steve Wilson. "Tom Ogilvy" wrote in message ... Just move it with the same name using the code provided. OldName = "C:\MYDIR\OLDFILE.xls": NewName = "C:\YOURDIR\OLDFILE.xls" -- Regards, Tom Ogilvy "Always Learning" <NoMoreSpam@MyEmail wrote in message ... Hi Rob, Fantastic. Works like a charm, Thank you. Is there a way that I can just copy the file rather than renaming and then deleting the file so I leave everything as it was? I appreciate your help. Best Regards, Steve Wilson. "Rob van Gelder" wrote in message ... Name statement: Dim OldName, NewName OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names. Name OldName As NewName ' Rename file. OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE" Name OldName As NewName ' Move and rename file. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Always Learning" <NoMoreSpam@MyEmail wrote in message ... Good morning guys, does any one know how I can rename a file using VBA code. I display a file dialog box allowing the user to pick a .csv file. Because of the quirks of Excel I need that file to come in as a .Txt file. I do not want the user to have to rename the file as the existing ..csv file is created by a third party program. My VBA macro then reads the ..Csv file and does it's thing. I need it to be .Txt. How do I rename the file in the directory before I open it. Thanks for any help. Best Regards, Steve Wilson. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
rename excel file name | Excel Discussion (Misc queries) | |||
problem after rename of file | Excel Discussion (Misc queries) | |||
FILE AUTO-RENAME | Excel Discussion (Misc queries) | |||
How to set SAVE AS file name to equal A1 contents when rename file | Excel Discussion (Misc queries) | |||
Rename File from list | Excel Programming |