Tuesday, October 26, 2010

FileCopy/FileCopyA

The VBA FileCopy statement will not copy files that are open. However, the WordBasic equivalent will (this is what is known as progress!).

The following works even if the file being copied is open:

If Left$(Application.Version, 1) = "8" Then
'Word 97
WordBasic.CopyFile FileName:="c:\OldTempDirectory\Temp1.doc", _
Directory:="C:\NewDirectory\Temp2.doc"
Else
'Word 2000 and above
WordBasic.CopyFileA FileName:="c:\OldTempDirectory\Temp1.doc", _
Directory:="C:\NewDirectory\Temp2.doc"
End If

No comments: