In the following “overwrite” is incorrect. I would like to leave in “source” and “Destination” but it seems the only way forward is to drop all names as in second script?
Const initialFileDump As String = "C:\"
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile _
Source:=initialFileDump & "\" & "test.xlsx", _
Destination:=initialFileDump & "\" & "testnew.xlsx", _
overwrite:=True
Script2
Const initialFileDump As String = "C:\"
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile _
initialFileDump & "\" & "test.xlsx", _
initialFileDump & "\" & "testnew.xlsx", _
True
Is there a way to leave in the first two names?
It’s OverWriteFiles
rather than Overwrite
. It’s always worth adding the references to Microsoft.Scripting.Runtime
so you get the intelli-sense with parameters expected.
Tags: excelexcel