XL97: Help Argument for MsgBox Function Behaves Differently

Last reviewed: February 27, 1998
Article ID: Q164500
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SUMMARY

In Microsoft Excel 97, when you use the MsgBox function to display a Help button in a message box, the Visual Basic for Applications procedure you use is different from the procedure you use in earlier versions of Microsoft Excel. The MsgBox function requires a new constant, vbMsgBoxHelpButton, to display a Help button. You must use the constant in combination 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 you provide the information for the Helpfile and Context named arguments.

MORE INFORMATION

The MsgBox function in Visual Basic for Applications displays a message in a dialog box, waits for the user to click a button, and returns an integer that indicates which button the user clicked. The buttons displayed in the dialog box may vary, depending on the constants you use with the MsgBox function.

Microsoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

Example

The following macro example uses the vbMsgBoxHelpButton constant to display 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 97

In earlier versions of Microsoft Excel, when you create a file that contains a macro that uses the MsgBox function to display a Help button and you open the file in Microsoft Excel 97, there are several issues to consider. 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.

REFERENCES

For more information about the MsgBox Function, click the Index tab in Microsoft Visual Basic for Applications Help, type the following text

   msgbox

and then double-click the selected text to go to the "MsgBox function" topic.


Additional query words: xl97vbmigrate
Keywords : kbprg
Version : WINDOWS:97
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.