下面的代码试图将文件从文件夹复制到另一个目录。
即使文件存在,也无法找到文件。
select distinct split(myfield, ',')
答案 0 :(得分:1)
与FileSystemObject相比,我更喜欢使用DIR,因为前者是本机函数。这是将文件从一个文件夹复制到另一个文件夹的代码。如果需要,您还可以使用DIR遍历所有文件。
Option Explicit
Sub CopyFiles()
Dim fldrpath As String
Dim sSourcePath As String
Dim sFile As String, source_file As String
sSourcePath = "\\oak\data\Placeholder\APP\VMP0\sxv0_out"
sFile = "Placeholder.csv"
fldrpath = "W:\Placeholder\2018\10. Oct\"
source_file = Dir(sSourcePath & "\" & sFile)
If Trim(source_file) <> vbNullString Then
If Dir(fldrpath, vbDirectory) = vbNullString Then MkDir fldrpath
FileCopy sSourcePath & "\" & sFile, fldrpath & sFile
MsgBox "Specified File Copied Successfully", vbInformation, "Done!"
Else
MsgBox "Specified File Not Found", vbInformation, "Not Found"
End If
End Sub