Changing name to txt external file

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
 
B

Brendan Reynolds

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
 
K

kerry_ja

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top