Microsoft KB Archive/236808

= OFF2000: New Behavior with MsgBox Function =

Article ID: 236808

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition
 * Microsoft Access 2000 Standard Edition
 * Microsoft FrontPage 2000 Standard Edition
 * Microsoft PowerPoint 2000 Standard Edition
 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q236808





SYMPTOMS
In Microsoft Office 2000, when you use the MsgBox function in Visual Basic for Applications to display a Help button in a message box, the procedure may be different from the procedure that you used in earlier versions of the product. The vbMsgBoxHelpButton constant is needed to display a Help button. You must use the constant in combination with the Helpfile and Context arguments.

In earlier versions of Visual Basic for Applications, when you use the MsgBox function, no constants are required to display a Help button in a message box. Instead, the MsgBox function displays a Help button automatically if you just include information for the Helpfile and Context named arguments.



CAUSE
This behavior first changed in Microsoft Excel 97. Now the MsgBox function has the same behavior throughout all Microsoft Office products that use the Visual Basic Editor. The behavior is now the same as it is in Microsoft Visual Basic.



RESOLUTION
If you have upgraded from an earlier product in which you used a MsgBox function that specified a Help file, you may need to add the vbMsgBoxHelpButton constant as demonstrated in the "More Information" section of this article.



MORE INFORMATION
The MsgBox function waits until you click a button, and then it returns an integer indicating which button you clicked. The buttons displayed in the dialog box may vary, depending on the constants specified in the function.

Example
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. The following procedure uses the vbMsgBoxHelpButton constant to display a Help button in a message box: Sub MsgBox_Test 'Dimension variables. Dim Msg, Style, Title, Help, Ctxt, Response, MyString

'Set the values of variables used by the MsgBox Function. Msg = "Do you want to create a template?" 'Define message. Style = vbYesNo + vbMsgBoxHelpButton       'Define buttons. Title = "MsgBox Demonstration"             'Define title. Help = "xlmain8.hlp"                       'Define Help file. Ctxt = 2017                                'Define topic context.

'Display the message box. Response = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then   'User clicks Yes. MyString = "Yes"       'Perform some action. Else                       'User chose No. MyString = "No"        'Perform some action. End If End Sub

