OFF2000: New Behavior with MsgBox Function

ID: Q236808


The information in this article applies to:
  • Microsoft Office 2000


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, 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 Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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:

Q236806 OFF2000: MsgBox Function Example Does Not Use vbMsgBoxHelpButton Constant

Additional query words: OFF2000 ACC2000 XL2000 WORD2000 PPT2000 FP2000

Keywords : kbdta kbdtacode AccCon
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


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