OFF2000: New Behavior with MsgBox Function (236808)



The information in this article applies to:

  • Microsoft Excel 2000
  • Microsoft Access 2000
  • Microsoft FrontPage 2000
  • Microsoft PowerPoint 2000
  • Microsoft Word 2000

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
				

REFERENCES

For additional information about the MsgBox Help example, click the article number below to view the article in the Microsoft Knowledge Base:

236806 OFF2000: MsgBox Function Example Does Not Use vbMsgBoxHelpButton Constant


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kbprb KB236808