WD: How to Close an InputBox$() Dialog Box Using Keystrokes

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 Macintosh Edition


SUMMARY

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


MORE INFORMATION

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 box.

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:
Q176476 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 professionals 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 box 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 box 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 box.

Additional query words: InputBox$() input box paragraph enter newline

Keywords : kbmacro kbprg kbdta kbdtacode wordnt kbmacroexample macword98 winword ntword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1; WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; winnt:6.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbinfo


Last Reviewed: December 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.