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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rename an external file

Status
Not open for further replies.

rorymurray

Programmer
Oct 16, 2001
44
AU
Does anyone know how to use access to rename a file. I basically want to change something from "filename.650" to "filename.txt"
 
So I would do something like:

sub change_name(path as string)

'Remove the "650" from the end

dim newpath as string

newpath = left(path,(len(path-3)) & "txt"

Name path as newpath

end sub


Is this correct?
 
No
sub change_name(path as string)
'Remove the "650" from the end
dim newpath as string
'***newpath = left(path,(len(path-3)) & "txt"
if Len(path) >= 3 then ' bulletproof it
newpath = left(path,len(path)-3) & "txt"
Name path as newpath
End if
end sub

Compare Code (Text)
Generate Sort in VB or VBScript
 
Don't forget to add the "." before the TXT Terry M. Hoey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top