Retreiving a Directory

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

Guest

Is there an object that will allow you to get a directory of a file? What I want to be able to do is get a directory of a file and copy that file to another location.
 
Joethis,

'The following will retrieve the path to the specified file:
sPath = Replace(sFileName, Dir(sFileName, vbNormal), "")

'The following will move a file from one location to another:
Name sFileName As sNewFileName

But to do that you need three things:
1. The existing filename (including its current path), which is given by
you in sFileName.
2. The filename portion, which is given by the following code:
Dir(sFileName, vbNormal)
3. The new path (excluding the filename), which is given by you in
sNewPath.

Therefore, the code should be:
sFile = Dir(sFileName, vbNormal)
Name sFileName As sNewPath & "\" & sFile

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


joethis said:
Is there an object that will allow you to get a directory of a file? What
I want to be able to do is get a directory of a file and copy that file to
another location.
 
Back
Top