M
MM
I have some code to rename image files from a query so they can be
used on a web site. It works fine if no file exists but I'm having
touorble getting it to overwrite existing files. Any suggestions how
to make it overwrite existing files or move the existing ones somwhere
else?
Private Sub ImageRename_Click()
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim strOrigFolder As String
Dim strOrigFile As String
Dim strNeedFolder As String
Dim strNeedFile As String
Dim strNoNeedFolder As String
Dim strNoNeedFile As String
Dim strSQL As String
' Define what folder the pictures are in.
' Note that the final slash must be there
strOrigFolder = "C:\LocalFiles\Images\"
strNeedFolder = "C:\LocalFiles\Images\web\product\"
' Define the SQL to get the data from the table.
strSQL = "SELECT [Image], [OutItem] FROM tblImages;"
Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(strSQL)
Do While rsCurr.EOF = False
strOrigFile = strOrigFolder & rsCurr![Image] & ".jpg"
strNeedFile = strNeedFolder & rsCurr![OutItem] & ".jpg"
'Copy Needed files (good on February 2nd)
If (Len(Dir(strOrigFile)) > 0) And (Len(Dir(strNeedFile)) > 0) Then
Name strOrigFile As strNeedFile
Else
End If
rsCurr.MoveNext
used on a web site. It works fine if no file exists but I'm having
touorble getting it to overwrite existing files. Any suggestions how
to make it overwrite existing files or move the existing ones somwhere
else?
Private Sub ImageRename_Click()
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim strOrigFolder As String
Dim strOrigFile As String
Dim strNeedFolder As String
Dim strNeedFile As String
Dim strNoNeedFolder As String
Dim strNoNeedFile As String
Dim strSQL As String
' Define what folder the pictures are in.
' Note that the final slash must be there
strOrigFolder = "C:\LocalFiles\Images\"
strNeedFolder = "C:\LocalFiles\Images\web\product\"
' Define the SQL to get the data from the table.
strSQL = "SELECT [Image], [OutItem] FROM tblImages;"
Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(strSQL)
Do While rsCurr.EOF = False
strOrigFile = strOrigFolder & rsCurr![Image] & ".jpg"
strNeedFile = strNeedFolder & rsCurr![OutItem] & ".jpg"
'Copy Needed files (good on February 2nd)
If (Len(Dir(strOrigFile)) > 0) And (Len(Dir(strNeedFile)) > 0) Then
Name strOrigFile As strNeedFile
Else
End If
rsCurr.MoveNext