The information in this article applies to:
SYMPTOMSIn the versions of Microsoft Excel listed at the beginning of this article, when you use the Shell function in a Visual Basic for Applications macro to execute an external MS-DOS call, if you use commands contained only in the MS-DOS core, you receive the following error message: The commands that return this error message are the following: DIR, CLS, DEL, CD, MD, RD, MKDIR, RMDIR, COPY CAUSEThis problem occurs because the Shell function in Microsoft Excel does not start a specific instance of the MS-DOS command interpreter (Command.com). 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. WORKAROUND
To work around this problem, perform the commands that cause the error
message from within Microsoft Excel.
NOTE: The Visual Basic for Applications Dir command does not function
identically to its MS-DOS equivalent, and requires extra code to
retrieve an entire directory.
For more information about the Dir command in Visual Basic for Applications, click the Index tab in Microsoft Excel Help, type the following text dirand then double-click the selected text to go to the "Dir function" topic. In cases where it is absolutely essential to use one of the MS-DOS core commands, it is possible to invoke an instance of the command interpreter manually and pass it the desired command. To do this, use the following syntax:
NOTE: you must include /c for the command to be executed correctly. For
example, to perform a directory command of all hidden files in the root
directory, use the following syntax:
MORE INFORMATIONIn a normal MS-DOS session when you are using Windows 3.1 or Windows 95, the MS-DOS command interpreter, Command.com, is present to handle core commands. To show that the MS-DOS command interpreter, Command.com, is not in memory, use the following Visual Basic for Applications command:
Compare this to the output of the MEM command when you run it from an MS-
DOS session under Windows or Windows 95. The only difference is that
Command.com is not in memory within the environment created by the
Visual Basic for Applications Shell function.
Additional query words: 5.00c 97 8.00 XL97
Keywords : kbprg kbdta KbVBA xlwin |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |