WD: Closing an InputBox$() Dialog Using Keystrokes

Last reviewed: March 13, 1998
Article ID: Q108629
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SUMMARY

This article discusses the keystrokes needed to close the dialog displayed when using the InputBox command.

MORE INFORMATION

Word 97 for Windows or Word 98 Macintosh Edition

The Visual Basic for Applications InputBox command accepts only one line of text. Pressing ENTER (RETURN in Word for the Macintosh) closes the InputBox dialog.

For more information about InputBox, from the Visual Basic for Applications Editor, click the Office Assistant, type "InputBox," click Search, and then click to view "InputBox."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176476
   TITLE     : OFF: Office Assistant Not Answering Visual Basic Questions

Word 6.x, 7.x

In Word 6.x-7.x, you can enter a new line by pressing ENTER (RETURN in Word for the Macintosh), but as a result, this key will not click the OK button.

To close an InputBox$() in Word 6.x-7.x, you must press the TAB key and then press ENTER. The TAB key moves the focus to the OK button so that when you press the ENTER key, the dialog box is closed.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/

If you want the user to type a single line of data and be able to press the ENTER key to close the dialog box, you can use a WordBasic user-defined dialog instead of an InputBox, for example:

   Sub MAIN
      Begin Dialog UserDialog 320, 144, "Microsoft Word"
         TextBox 10, 66, 292, 18, .TextBox1
         OKButton 10, 6, 88, 21
         CancelButton 10, 30, 88, 21
      End Dialog
      Dim dlg As UserDialog
      n = Dialog(dlg)
      If n = -1 then Insert dlg.textbox1
   End Sub

If your dialog box needs to use a multiple line edit box, you can add a shortcut key to the OK button using a WordBasic Dialog function. The OK button shortcut key allows you to close the dialog without using the mouse (press ALT+O), for example:

   Sub MAIN
      Begin Dialog UserDialog 320, 144, "Microsoft Word", .dialogfunction
         TextBox 10, 66, 292, 36, .TextBox1, 1
         OKButton 10, 6, 88, 21
         CancelButton 10, 30, 88, 21
      End Dialog
      Dim dlg As UserDialog
      n = Dialog(dlg, - 1)
      If n = - 1 Then Insert dlg.textbox1
   End Sub

   Function dialogfunction(ID$, Action, Suppval)
      If action = 1 Then DlgText "OK", "&OK"
   End Function

Word 2.x

In Word 2.x, you pressed SHIFT+ENTER to enter a new line in an Inputbox$. Pressing ENTER closes the Inputbox dialog.


Additional query words: InputBox$() input box paragraph enter newline
Keywords : kbmacroexample macword ntword winword word6 word7 word8 word95 word97 wordnt macword98 kbcode kbmacro kbprg
Version : WINDOWS:2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a,97; MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform : MACINTOSH WINDOWS
Issue type : kbinfo


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: March 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.