XL97: Help Argument for MsgBox Function Behaves Differently
This article was previously published under Q164500
This article has been archived. It is offered "as is" and will no longer be updated.
In Microsoft Excel 97, when you use the MsgBox function to display a Helpbutton in a message box, the Visual Basic for Applications procedure youuse is different from the procedure you use in earlier versions ofMicrosoft Excel. The MsgBox function requires a new constant,vbMsgBoxHelpButton, to display a Help button. You must use the constant incombination with the Helpfile and Context arguments.In earlier versions of Microsoft Excel, when you use the MsgBox function,no constants are required to display a Help button in a message box.Instead, Microsoft Excel automatically displays a Help button if youprovide the information for the Helpfile and Context named arguments.
The MsgBox function in Visual Basic for Applications displays a message ina dialog box, waits for the user to click a button, and returns an integerthat indicates which button the user clicked. The buttons displayed in thedialog box may vary, depending on the constants you use with the MsgBoxfunction.
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 Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
ExampleThe following macro example uses the vbMsgBoxHelpButton constant todisplay a Help button in a message box:
Sub MsgBox_Help_Example() '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
Issues to Consider When You Upgrade to Microsoft Excel 97In earlier versions of Microsoft Excel, when you create a file thatcontains a macro that uses the MsgBox function to display a Help buttonand you open the file in Microsoft Excel 97, there are several issues toconsider. These issues are the following:
- The Help button does not appear in the message box until you edit the macro; the macro must use the new constant, vbMsgBoxHelpButton.
- The name of the Help file may be different.
- The context ID of the Help topic may be different.
For more information about the MsgBox Function, click the Index tab inMicrosoft Visual Basic for Applications Help, type the following text
msgboxand then double-click the selected text to go to the "MsgBox function"topic.
Article ID: 164500 - Last Review: 10/04/2013 21:14:55 - Revision: 2.4
Microsoft Excel 97 Standard Edition
- kbnosurvey kbarchive kbprogramming KB164500