Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Removing a Directory.
by Allen Wyatt
(last updated April 5, 2014)
In another issue of WordTips you learn how to create a directory in a macro using the MkDir command. There are times that programmers (even macro programmers) create directories to store temporary files. When they are done, the files are deleted and the directory is removed. To remove a directory, you use the RmDir command in your macro, as shown here:
where DirName is the full pathname of the directory you want to delete. If you do not use a string variable to specify the directory name, then DirName must be enclosed in quotes. If there are any files in the directory or any subdirectories contained in the subdirectory, the command fails with an error. (This means you should delete all the files and subdirectories before trying to remove a directory with RmDir.)
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (3432) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Removing a Directory.
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!
One of the basic programming structures used in VBA is the While ... Wend structure. This structure helps to make the ...Discover More
Want to grab some interactive input from a user in your macro? The best way to do that is with the InputBox function, ...Discover More
When a macro works with files, it often has to change between different directories on your disk drive. This is done using ...Discover More