เพิ่มเป็นแบบนี้นะครับ
เวลาคุณกดบันทึกไฟล์ มันจะลบไฟล์เก่าต้นทางทิ้ง
Private Sub Command13_Click()
Call Copy
End Sub
Private Sub Import_Click()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
f.Filters.Clear
f.Filters.Add "Picture Files", "*.bmp;*.jpg;*.gif;*.png"
If f.Show Then
For i = 1 To f.SelectedItems.Count
sFile = filename(f.SelectedItems(i), sPath)
Me.GetFileName = sFile
Me.GetFilePath = sPath
Next
End If
End Sub
Sub Copy()
Dim sPath, sfilename, sLink, Snow, sCopyInto, myOutput As String
Dim fso As Object
Dim DeletePath As String
Set fso = CreateObject("Scripting.FileSystemObject")
Snow = Now
Snow = Format(Date, "YYYYMMDD")
sfilename = GetFileName
myOutput = Right(sfilename, Len(sfilename) - InStrRev(sfilename, "."))
sPath = GetFilePath
sLink = sPath & sfilename
sCopyInto = "D:\iDoc\" & Me.NewName & Snow & "." & myOutput
fso.CopyFile sLink, sCopyInto
DeletePath = GetFilePath & GetFileName
If fso.FileExists(DeletePath) Then
fso.DeleteFile DeletePath
End If
Set fso = Nothing
End Sub
Public Function filename(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, "\"))
filename = Mid(strPath, InStrRev(strPath, "\") + 1)
End Function