Please Note: This article is written for users of the following Microsoft Word versions: 2007 and 2010. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Copying a File in VBA.
by Allen Wyatt
(last updated June 26, 2018)
Word uses a macro programming language known as Visual Basic for Applications, or VBA. Many of the tasks you can perform in regular Visual Basic you can also perform in VBA. One such task is to copy files. You can do so by using the FileCopy command, as follows:
FileCopy source, target
Of course, you need to provide the appropriate specifications for both the source and target designations. For instance, if you wanted to copy a file named MyFile.Doc from the current directory to the F: drive (perhaps where you have a thumb drive) you could do so:
FileCopy myfile.doc, f:
If you try to copy a file that is currently open (either by Word or through a different program), VBA generates an error.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (5915) applies to Microsoft Word 2007 and 2010. You can find a version of this tip for the older menu interface of Word here: Copying a File in VBA.
Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!
If you need to determine a random value in a macro, you can do so using the Rnd function. This tip presents the syntax ...Discover More
Need to find out in a macro how long a particular text string is? You can figure it out by using the Len function, ...Discover More
Do you need to step through a table, cell by cell, in a macro? It's easy to do using the Move method, as described in ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.