MrExcel Publishing
Your One Stop for Excel Tips & Solutions

VBA: Is it possible to use DOS command Copy *.* Filename in macro

Posted by Stephen on October 06, 2000 3:18 PM

I need to be able to grab multible files out of a subfolder and combine them in to one file. The DOS the command is Copy *.* Filename. Is this possible in a macro. Thanks

Posted by Ivan Moala on October 06, 2000 4:39 PM

Do you mean you want to copy files to a Dir ??
and not a file ? If so then initially I thought
of the shell command however The Shell function in Microsoft Excel does not start a specific instance of the MS-DOS command interpreter ( Therefore, the MS-DOS core commands are not present. Only files that have an .exe, .com or .bat extension can be executed through the Shell function.

You can perform most of the functions that are provided by through commands included in Microsoft Excel Visual Basic for Applications. Some common core MS-DOS commands and their

The command you are after is the FileCopy
From help;

Dim SourceFile, DestinationFile
SourceFile = "SRCFILE" ' Define source file name.
DestinationFile = "DESTFILE" ' Define target file name.
FileCopy SourceFile, DestinationFile ' Copy source to target.