ID: Q86709
The information in this article applies to:
In Microsoft Word, the WordBasic CopyFile command allows a specified file to be copied to another directory location. The syntax and function of this command are similar to those of the MS-DOS Copy command.
The following macro copies the Test.doc file from the C:\Winword directory to the C:\Backup directory:
Sub MAIN
CopyFile "C:\winword\test.doc", "C:\backup"
End Sub
NOTE: If a file of the same name already exists in the target directory, a
message asking if you want to replace the existing file is displayed.
Syntax:
CopyFile Filename$, Directory$
If a drive and directory are not specified in the Filename$ parameter, Word
for Windows copies the specified file from the current directory.
The Directory$ parameter for the CopyFile command should include the full path of the directory to which you want to copy the file.
The following sample macro copies the active document file to drive B:
Sub MAIN
FileSave 'save the current file
a$ = FileName$() 'get the current filename
CopyFile a$, "b:\" 'copy the active file to the B drive
End Sub
NOTE: The CopyFile command is not available in version 1.x of Word for
Windows.
NOTE: Information provided in this document is provided 'as is' without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
For Macintosh users the syntax for CopyFile is the same as above:
CopyFile .FileName = text, .Directory = text
The .Directory parameter specifies the folder path to the file's location
or to where it is to be saved. For example "Macintosh HD:Desktop
Folder:Word Document"
The following macro will make a copy of the file named "Test" in the Microsoft Word 6 folder and save it to the desktop.
Sub MAIN
CopyFile "Mac HD:Microsoft Office:Microsoft Word 6:Test", "Mac \
HD:Desktop Folder:Test"
End Sub
"Using WordBasic," by WexTech Systems and Microsoft, page 166
Additional query words: copy file macword
Keywords : kbmacro kbmacroexample winword word6 winword2 word7 word95 kbhowto
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.6.0.1a
Platform : MACINTOSH WINDOWS
Issue type : kbinfo
Last Reviewed: February 4, 1998