WD: Macro Command for Copying FilesLast reviewed: February 2, 1998Article ID: Q86709 |
The information in this article applies to:
SUMMARYIn 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.
MORE INFORMATION
Word for WindowsThe 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 SubNOTE: 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 SubNOTE: 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.
Word 6.x for the MacintoshFor Macintosh users the syntax for CopyFile is the same as above:
CopyFile .FileName = text, .Directory = textThe .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 REFERENCES"Using WordBasic," by WexTech Systems and Microsoft, page 166
|
Additional query words: copy file macword
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |