Search code examples
pythonwinapimessageboxxlwings

xlwings: How to acquire the value of the cell and to indicate message box


I'm using xlwings on a Windows. I acquire the value of the cell and want to indicate message box.

import xlwings as xw
import win32ui

def msg_box():
    wb = xw.Book.caller()
    win32ui.MessageBox(xw.sheets[0].range(4, 1).value,"MesseageBox")

However, Python stops. Could anyone help me to fix it? Thank you.


Solution

  • On Windows, something like this should work as a workaround:

    import xlwings as xw
    import win32api
    
    def msg_box():
        wb = xw.Book.caller()
        win32api.MessageBox(wb.app.hwnd, "YourMessage")