XLL+ Class Library (7.0)


Display the Excel message box

static BOOL XlMessageBoxW(
   const wchar_t* pszText,
   XlMessageBoxTypes usType



A null-terminated string that will be displayed in the message box.


If usType is XlMessageBoxTypeQuestion (1), XlMessageBox will display a dialog with OK and Cancel buttons; the icon will be a question mark. If usType is XlMessageBoxTypeInformation (2), then an information icon will be displayed, and only the OK button will be available. If usType is XlMessageBoxTypeExclamation (3), then a warning icon will be displayed, and only the OK button will be available.

Return Value

TRUE if the user presses OK; FALSE if the user presses Cancel


This function displays an Excel message box containing the text parameter, an icon, the OK button and optionally the Cancel button. It is equivalent to calling the Excel ALERT macro.

Since the function is static, it is not necessary to use an instance of CXllApp to invoke it. It is not therefore necessary to fix the MFC CWinApp instance using the XLL_FIX_STATE macro: you can use code such as:

if ( CXllApp::XlMessageBox("Refresh data now?", 1) )

If you need more flexibility from a message box, use the Windows MessageBox via CXllApp::WinMessageBox, or create your own dialog class and show it using an instance of CExcelWnd as the parent CWnd.


Header: xllplus.h

See Also

CXllApp Class | CXllApp Methods | CXllApp::WinMessageBox | CXllApp::XlHwnd | CExcelWnd