I used this code that worked very well but i want the file name must be a variable that i can change it using combo box located in my form. I mean the name of the file with its extension must a variable. (database.txt as a variable)
Code:
Function GetFSO() As Object ' Scripting.FileSystemObject
On Error Resume Next
Set GetFSO = CreateObject("Scripting.FileSystemObject")
End Function
Sub FSOCopyFile(fso As Object, sourceFolder As String, _
destinationFolder As String, Optional overwrite As Boolean = True)
fso.CopyFile sourceFolder, destinationFolder, overwrite
End Sub
Private Sub Command2_Click()
Dim fso As Object ' Scripting.FileSystemObject
Set fso = GetFSO
If fso Is Nothing Then
Exit Sub
End If
' copyfile example
FSOCopyFile fso, "D:\database.txt", "D:\lictures\"
End Sub