Home » excel » excel – Named Argument not found

excel – Named Argument not found

Posted by: admin April 23, 2020 Leave a comment

Questions:

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?

How to&Answers:

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.

enter image description here