Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming an Excel File

Status
Not open for further replies.

DanSc0tt

MIS
Sep 17, 2001
30
0
0
DE
Any idea what piece of code I can use to rename an excel file on my desktop from inside Access, I have seen the simple "kill" command to delete stuff, but wondered if there was a similar one to rename stuff??

Dan
 
I have never seen a specific rename function, but a way of acheiving this, is to use FileCopy function & give the destination file your 'rename' name. Then use the kill function to delete the original file...

e.g
FileCopy("c:\SourceFile.xls", "c:\DestinationFile.xls")
Kill "c:\SourceFile.txt


Check the syntaxes first though... James Goodman
 

Use the Name function in Access VBA.

Name Statement Examples from Access Help.

Dim OldName, NewName

OldName = "OLDFILE" ' Define file names.
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. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top