Changing name to txt external file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

i export a table from access to a txt file. now i want to rename the file
with vba code. is that possible??

other solution would be to export the file with the correct name, but i dont
know how to specify the name from a macro
the file must be named "21042006 150700.txt" ( now() )

any ideas...?

thanks
 
Though it seems to be undocumented now, the old BASIC Name ... As ... syntax
still works in VBA ...

Public Sub TestName()

Name CurrentProject.Path & "\cws.xml" As CurrentProject.Path &
"\renamed.xml"

End Sub
 
Hi Roy,

I think the easiest way would be to export it with the correct name,
which is probably just changing the name in quotes above, but to rename
a file, one way is through the File System Object as in the following
example:

Dim objFileSystem As Object
Dim objFile As Object
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile("Old File Path/Name")
Let objFile.Name = "New File Name"
 
Back
Top