Microsoft KB Archive/167137: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 69: | Line 69: | ||
# From the Inbox, on the File menu, point to New and click Mail message. | # From the Inbox, on the File menu, point to New and click Mail message. | ||
# On the message form Tools menu, click | # On the message form Tools menu, click "Design Outlook Form" to enter the form design mode. | ||
# Click the form (P.2) tab, and on the Form menu, click | # Click the form (P.2) tab, and on the Form menu, click "Display This Page." | ||
# On the Form menu, click | # On the Form menu, click "Control Toolbox." Drag the Command Button to the form. | ||
=== Creating the VBScript to Return the User Name === | === Creating the VBScript to Return the User Name === | ||
<ol> | <ol> | ||
<li>On the Form menu, click | <li>On the Form menu, click "View Code" to open the VBScript editor.<br /> | ||
<br /> | <br /> | ||
NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in VBScript.</li> | NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in VBScript.</li> | ||
Line 83: | Line 83: | ||
Sub CommandButton1_Click() | Sub CommandButton1_Click() | ||
'Message box that returns the current user's name | 'Message box that returns the current user's name | ||
MsgBox | MsgBox "The current user is " & _ | ||
Application.GetNameSpace( | Application.GetNameSpace("MAPI").CurrentUser | ||
End Sub | End Sub | ||
</pre></li> | </pre></li> | ||
<li>On the Script Editor File menu, click Close.</li> | <li>On the Script Editor File menu, click Close.</li> | ||
<li>On the form Tools menu, click | <li>On the form Tools menu, click "Design Outlook Form" to exit the form design mode.</li></ol> | ||
If you click CommandButton1, you will see a message box that contains the current user's name. | If you click CommandButton1, you will see a message box that contains the current user's name. |
Revision as of 11:03, 21 July 2020
Article ID: 167137
Article Last Modified on 2/12/2007
APPLIES TO
- Microsoft Outlook 97 Standard Edition
This article was previously published under Q167137
SUMMARY
This article describes how to use Visual Basic Scripting Edition (VBScript) with Microsoft Outlook 97 to return the current user name.
MORE INFORMATION
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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
The following example uses a message form, one command button, and a message box to return the current user's name.
Creating the Form and CommandButton Control
- From the Inbox, on the File menu, point to New and click Mail message.
- On the message form Tools menu, click "Design Outlook Form" to enter the form design mode.
- Click the form (P.2) tab, and on the Form menu, click "Display This Page."
- On the Form menu, click "Control Toolbox." Drag the Command Button to the form.
Creating the VBScript to Return the User Name
- On the Form menu, click "View Code" to open the VBScript editor.
NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in VBScript. Type the following code into the editor window:
'Sub routine that runs when you click CommandButton1 Sub CommandButton1_Click() 'Message box that returns the current user's name MsgBox "The current user is " & _ Application.GetNameSpace("MAPI").CurrentUser End Sub
- On the Script Editor File menu, click Close.
- On the form Tools menu, click "Design Outlook Form" to exit the form design mode.
If you click CommandButton1, you will see a message box that contains the current user's name.
REFERENCES
For more information about creating solutions with Microsoft Outlook 97, please see the following articles in the Microsoft Knowledge Base:
Additional query words: OutSol OutSol97
Keywords: kbdswnet2003swept kbhowto kbprogramming KB167137