Chào cả nhà
Em có đoạn code như thế này
Em muốn hỏi hàm nào dùng để kiểm tra PicName có tồn tại trong sfol hay chưa?
Và đoạn code thế này đã đúng chưa?
Thanks cả nhà
Sub Check()
Dim fso
Dim sfol As String, dfol As String, PicName As String
PicName = "503-0810.JPG"
sfol = "E:\Test" '
dfol = "E:\Test_2"
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If Not fso.FolderExists(sfol) Then
MsgBox sfol & " is not a valid folder/path."
If Not fso.FileExists(PicName) Then
MsgBox PicName & " is not exist."
ElseIf Not fso.FolderExists(dfol) Then
MsgBox dfol & " is not a valid folder/path."
Else
fso.CopyFile (PicName), dfol
End If
End If
If Err.Number = 53 Then MsgBox "File not found"
End Sub
Em có đoạn code như thế này
Em muốn hỏi hàm nào dùng để kiểm tra PicName có tồn tại trong sfol hay chưa?
Và đoạn code thế này đã đúng chưa?
Thanks cả nhà
Sub Check()
Dim fso
Dim sfol As String, dfol As String, PicName As String
PicName = "503-0810.JPG"
sfol = "E:\Test" '
dfol = "E:\Test_2"
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If Not fso.FolderExists(sfol) Then
MsgBox sfol & " is not a valid folder/path."
If Not fso.FileExists(PicName) Then
MsgBox PicName & " is not exist."
ElseIf Not fso.FolderExists(dfol) Then
MsgBox dfol & " is not a valid folder/path."
Else
fso.CopyFile (PicName), dfol
End If
End If
If Err.Number = 53 Then MsgBox "File not found"
End Sub