Microsoft KB Archive/237273

= WD2000: Run-Time Error 438 When You Use WordBasic.CopyFile Command =

Article ID: 237273

Article Last Modified on 6/17/2005

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q237273



SYMPTOMS
In Microsoft Word 2000, when you use the WordBasic.CopyFile command, you receive the following error message:

Run-Time error '438':

Object doesn't support this property or method

For example, this problem occurs when you run the following macro code: Sub Test WordBasic.CopyFile "C:\My Documents\My Document.Doc", "C:\Backup\My Document.Doc" End Sub



WORKAROUND
To work around this problem, use the Visual Basic for Applications FileCopy command. The FileCopy command allows a specified file to be copied to another directory location.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

The following macro copies the file "My Document.Doc" from "C:\My Documents" to the folder "C:\Backup".

This example provides an error trap that alerts you when you need to take corrective steps to complete the operation.

Sub FileCopyExample Dim sSourcePath As String Dim sTargetPath As String

' Change these paths to your Source and Target paths. sSourcePath = "C:\My Documents\My Document.Doc" sTargetPath = "C:\Backup\My Document.Doc" On Error Resume Next

' Copy the file. FileCopy sSourcePath, sTargetPath

If Err > 0 Then MsgBox Err.Description End Sub NOTE: If you try to use the FileCopy statement on a file that is currently open, you receive the following error message:

Permission Denied

Unlike the WordBasic.CopyFile command, if a file of the same name already exists in the target directory, Word does not display a message asking whether you want to replace the existing file.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Additional query words: vb vba vbe

Keywords: kbbug kbmacroexample kbdtacode kbpending KB237273

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.