0
我想用修改後的名稱在不同位置創建excel文件的acopy。下面的代碼使用修改後的名稱移動文件而不是複製。VBA創建移動而不是移動文件
我不想從原始位置刪除文件只是想創建一個副本。請協助。與您可以asynchroneously恢復代碼的優勢
CreateObject("WScript.Shell").Run("cmd.exe /c xcopy /y /s """ & Source & """ """ & Dest & """", WindowStyle:=7 , WaitOnReturn:=(your boolean))
:
Dim myFileNameDir As String
Dim ws1 As Worksheet
myFileNameDir = Sheet1.Range("V9").Value & SPID1 & "\" & ComboBox29.Text
scor = ComboBox29.Text
scor = Replace(scor, ".", "")
MsgBox myFileNameDir
filenz = SPID1 & "_" & Emp1 & "_" & scor & "_" & VBA.Format(Now, "MMddyyyyhmmss AM/PM ")
Dim myfile As String
myfile = Sheet1.Range("V10").Value & filenz & ".xlsx"
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
Call fso.CopyFile(myFileNameDir, myfile)
是什麼讓你覺得這是移動文件,而不是複製?我只要求'FileSystemObject.CopyFile' **爲**複製**文件,**不是**移動它們。也許你的程序中有進一步的代碼會刪除原始代碼? – CLR