Microsoft KB Archive/213800

= In Office programs, you receive a "Specified COMMAND search directory had too many parameters" error message when you try to use an MS-DOS core command from the Shell function =

Article ID: 213800

Article Last Modified on 2/8/2007

-

APPLIES TO


 * Microsoft Office Access 2007
 * Microsoft Office Access 2003
 * Microsoft Access 2002 Standard Edition
 * Microsoft Access 2000 Standard Edition
 * Microsoft Access 97 Standard Edition
 * Microsoft Office Excel 2007
 * Microsoft Office Excel 2003
 * Microsoft Excel 2002 Standard Edition
 * Microsoft Excel 2000 Standard Edition
 * Microsoft Excel 97 Standard Edition
 * Microsoft Office PowerPoint 2007
 * Microsoft Office PowerPoint 2003
 * Microsoft PowerPoint 2002 Standard Edition
 * Microsoft PowerPoint 2000 Standard Edition
 * Microsoft PowerPoint 97 Standard Edition
 * Microsoft Office Word 2007
 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition
 * Microsoft Word 2000 Standard Edition
 * Microsoft Word 97 Standard Edition

-



This article was previously published under Q213800



SYMPTOMS
In Microsoft Office, when you use the Shell function in a Visual Basic for Applications macro to execute an external MS-DOS command, an MS-DOS window may open and you may receive the following error message:

Specified COMMAND search directory had

Too many parameters

The MS-DOS window is fully functional and the command you were attempting to run from the macro can be successfully run from the MS-DOS prompt. The commands that return this error message are the following:
 * DIR
 * CLS
 * DEL
 * CD
 * MD (MKDIR)
 * RD (RMDIR)
 * COPY



CAUSE
This behavior occurs if you have not used the /c switch in the macro. The /c switch is required to properly execute MS-DOS commands in a Visual Basic for Application macro.



RESOLUTION
To resolve this behavior, add the /c switch after command.com. For example to create a new directory called mydir, use the following code in a macro: Shell "command.com /c md c:\mydir" Note the /c switch after command.com.



MORE INFORMATION
You can perform most of the commands that are provided by command.com through statements and functions included in Microsoft Visual Basic for Applications. Some common core MS-DOS commands and their Microsoft Visual Basic equivalent statements are listed below.

MS-DOS      Visual Basic Statement/function

DEL         Kill CD          ChDir MD          MkDir RD          RmDir COPY        FileCopy DIR         Dir

Note For the correct syntax to use each Visual Basic statement, look up the statement in the Microsoft Visual Basic help. For example, to learn how to use Kill, type kill in the Answer Wizard and click Search.

Additional query words: VBA

Keywords: kbdtacode kberrmsg kbprb kbprogramming KB213800

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.