Dear All Master,

mohon pencerahan datri master, saya mau copy file ke folder tertentu, dengan 
case sebagai berikut :

1. apabila folder sumber tidak ditemukan maka muncul pesan"msgbox"Folder tidak 
ditemukan, then exit sub
2. apabila file yang dicopy dalam folder sumber tidak ada file excel nya maka 
muncul pesan "Msgbox" File excel tidak ditemukan" then exit sub
3. apabila folder ditemukan dan file ditemukan maka muncul pesan "Msgbox" Copy 
sukses" End Sub

berikut coding yang belum sempurna :

sub copyfile()
 Dim FSO As Object
    Dim FromPath As String
    Dim ToPath As String
    Dim FileExt As String
   
    FromPath = "D:\DataSEC"  '<< Change
    ToPath = "D:\Simulator VIPEC\SimVIPEC\Dbasesim"

    FileExt = "*.xl*"
    
    If Right(FromPath, 1) <> "\" Then
        FromPath = FromPath & "\"
    End If
 
    Set FSO = CreateObject("scripting.filesystemobject")

    If FSO.FolderExists(FromPath) = False Then
        MsgBox FromPath & " :  [Folder Tidak ditemukan]   ", vbOKOnly, "Error"
        Exit Sub
    End If
    If FSO.FolderExists(ToPath) = False Then
        MsgBox ToPath & " doesn't exist"
        Exit Sub
    End If
On Error Resume Next
    FSO.CopyFile Source:=FromPath & FileExt, Destination:=ToPath
  MsgBox "Copy Sukses..." & FromPath & " ke folder " & ToPath
  If Err.Number <> 0 Then
MsgBox "Files tidak ditemukan"
End If

End sub

File terlampir.

salam,
Along

Attachment: Copy File.xlsm
Description: application/vnd.ms-excel.sheet.macroenabled.12

Kirim email ke