A
ans
I need to copy files and rename the files.
The function below works ut it does not rename the copied files.
Function copyrename()
On Error Resume Next
MkDir "C:\copyrenamed"
Dim rs As DAO.Recordset
Dim strFileName As String
Dim strTargetFolder As String
strTargetFolder = "C:\copyrenamed\"
Set rs = CurrentDb.OpenRecordset("mypic")
' the table have the full path and name of the files I WANT TO COPY
' THE PATH of the file, and the filename (strfilename)
' the same table also has the description and I want the copied file to
' be called smth. like holiday2004_12345.png, easter2003_34567.bmp depending
of their decription
'
' this function only copy the file 12345.png to the new directory
'without renaming it
'
With rs
Do Until .EOF
strFileName = Dir(!path)
If Len(strFileName) = 0 Then
MsgBox "The file '" & !path & "' is not there!!"
Else
FileCopy !path, strTargetFolder & strFileName
End If
.MoveNext
Loop
.Close
End With
Set rs = Nothing
MsgBox "Done!"
End Function
The function below works ut it does not rename the copied files.
Function copyrename()
On Error Resume Next
MkDir "C:\copyrenamed"
Dim rs As DAO.Recordset
Dim strFileName As String
Dim strTargetFolder As String
strTargetFolder = "C:\copyrenamed\"
Set rs = CurrentDb.OpenRecordset("mypic")
' the table have the full path and name of the files I WANT TO COPY
' THE PATH of the file, and the filename (strfilename)
' the same table also has the description and I want the copied file to
' be called smth. like holiday2004_12345.png, easter2003_34567.bmp depending
of their decription
'
' this function only copy the file 12345.png to the new directory
'without renaming it
'
With rs
Do Until .EOF
strFileName = Dir(!path)
If Len(strFileName) = 0 Then
MsgBox "The file '" & !path & "' is not there!!"
Else
FileCopy !path, strTargetFolder & strFileName
End If
.MoveNext
Loop
.Close
End With
Set rs = Nothing
MsgBox "Done!"
End Function