Filecopy vs name function? Differences?

I found two different ways to copy single files in Excel using VBA. One of them is a copy of the file:

FileCopy (originalPath), (pathToCopyTo)

Another name:

Name (originalPath) As (pathToCopyTo)

Any differences in performance / intended use / functionality? I didn’t notice anything, but I wanted to know!

+4
source share
1 answer

In fact, they are very different things.

FileCopywill actually create a new copy of the file at the address pathToCopyTo, leaving the original file intact.

Namerenames the source file. Effectively moves the file if you provide a different file path. (The action is copy / paste.) Thus, the source file will not be where you found it, it will be in a new location.

. MSDN:

, Name , . . , , Cut/Paste , Copy/Paste.

+5

Source: https://habr.com/ru/post/1569556/


All Articles