Microsoft KB Archive/830258

= How to create a &quot;Masked Password&quot; dialog box in Office programs by using Visual Basic for Applications =

Article ID: 830258

Article Last Modified on 11/13/2006

-

APPLIES TO


 * 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 2003
 * Microsoft PowerPoint 2000 Standard Edition
 * Microsoft PowerPoint 2002 Standard Edition
 * Microsoft PowerPoint 97 Standard Edition
 * Microsoft Office Word 2003
 * Microsoft Word 2000 Standard Edition
 * Microsoft Word 2002 Standard Edition
 * Microsoft Word 97 Standard Edition

-





IN THIS TASK

 * SUMMARY
 * Create a Dialog Box
 * Code Sample to Use Dialog Box



SUMMARY
In Microsoft Excel, you can create a custom dialog box to prompt a user for information by using text boxes, buttons, or other dialog box controls. Typically, when you type text in a text box, the text appears as you type. However, you can use a property of the Microsoft Visual Basic for Applications (VBA) Edition User Form to create the effect of a hidden or &quot;masked&quot; text box. This can be useful for creating a password dialog box, where you do not want the text that is typed in a text box to be &quot;visible&quot;. The following information describes how to create this effect.

back to the top

Create a Dialog Box

 * 1) Start Excel.
 * 2) Press Alt+F11 to start the Microsoft Visual Basic Editor.
 * 3) On the Insert Menu, click User Form.
 * 4) Using the Controls Toolbox, add a text box and a command button on to your user form.
 * 5) In the Properties sheet, in the Object list, click TextBox1.
 * 6) On the Alphabetic tab, click PasswordChar.
 * 7) Type an asterisk ( * ).
 * 8) In the Properties sheet, in the Object list, click UserForm1.
 * 9) On the Run menu, click Run User Form.

When you type letters, the asterisk appears instead.

back to the top

Code Sample to Use Dialog Box
To retrieve the text string written to the text box, you can use the following sample code:  Double-click CommandButton1 on your user form.  Type the following code: Private Sub CommandButton1_Click MsgBox Me.TextBox1 End Sub  Click Save to save your project. On the Run menu, click Run Sub/User Form.

Type a word in the text box, and then click the Command button. The text that you typed appears in the message box.

back to the top

Keywords: kbhowtomaster KB830258

-

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

© Microsoft Corporation. All rights reserved.