Using Shell Statement to Access MS-DOS Prompt from WinWord

Last reviewed: July 30, 1997
Article ID: Q79696
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, version 7.0
  • Microsoft Word 97 for Windows

SUMMARY

From within Microsoft Word, you can use the WordBasic or Visual Basic for Applications Shell statement to access the MS-DOS prompt. You can assign this macro to a key, a menu, or a button.

MORE INFORMATION

The following steps create a macro to access the MS-DOS prompt from within Word.

Word 97

  1. On the Tools menu, point to Macro, and then click Macros.

  2. In the Macro Name box, type "dosprompt" (without the quotation marks), and click Create.

  3. In the macro editing window, type the following macro text:

          Shell "command.com", 1
    

  4. On the File menu, click "Close and Return to Microsoft Word."

For more information about adding macros to toolbars, menus, or keystrokes: from the Visual Basic Editor, click the Office Assistant, type "add toolbar keyboard menu command," click Search, and then click to view the appropriate topic.

Word for Windows Versions 6.0, 7.0

  1. On the Tools menu, point to Macro, and then click Macros.

  2. In the Macro Name box, type "dosprompt" (without the quotation marks), and click Create.

  3. In the macro editing window, type the following macro text:

          Shell "command.com", 1
    

  4. On the File menu, click Close. Click Yes when prompted to save changes to the macro.

  5. On the Tools menu, point to Customize, and select the Keyboard, Menu, or Toolbar Category to assign this macro to a key combination, menu, or toolbar button.

Word for Windows Version 2.0

  1. From the Tools menu, choose Macro.

  2. In the Macro Name box, type "dosprompt" (without the quotation marks), and then choose the Edit button.

  3. In the macro editing window, type the following macro text:

          Shell "command.com", 1
    

  4. From the File menu, choose Close. Choose the Yes button when prompted to save changes to the macro.

  5. From the Tools menu, choose Options, and select the Keyboard, Menu, or Toolbar Category to assign this macro to a key combination, menu or tool bar button.

For more information on the Shell statement, search for "WordBasic Programming Language" and "Shell" using the Help menu.

Word for Windows Version 1.x

  1. From the Macro menu, choose Edit.

  2. In the Edit Macro Name box, type "dosprompt" (without the quotation marks), and press the OK button.

  3. In the macro editing window, type the following macro text:

          Sub MAIN
          Shell "command.com", 1
          End Sub
    
       Note: In the Shell line, the following arguments can be used:
    
          0 for minimized window
          1 for normal window
          3 for maximized window
          4 for deactivated window
    
    

  4. From the File menu, choose Close. Choose the Yes button when prompted to save changes to the macro.

  5. From the Macro menu, you can choose the Assign to Key, or Assign to Menu commands to assign this macro to a key sequence or menu.

REFERENCES

"Microsoft Word for Windows and OS/2 Technical Reference," page 257

Kbcategory: kbusage kbmacro KBSubcategory:


Additional query words: 1.x 2.0 2.0a word6 7.0 word95 winword
word7 winword 2.0a-CD winword2 2.0b 2.0c 6.0 6.0a 6.0c word8
word97 8.0
Version : 1.x 2.x 6.0 6.0a 6.0c 7.0 7.
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.