-
-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create a messagebox? #756
Comments
Depending on exactly what you want to achieve this can be as simple as writing a VBA macro and calling it from pyrhon:
Actually, I was surprised it is that simple. HTH |
You can try with: import win32api
import win32con
import xlwings as xw
win32api.MessageBox(
xw.apps.active.api.Hwnd, 'Hello world!', 'Info',
win32con.MB_ICONINFORMATION) |
Worked Great!! @skasi7 Where could i find more information or documentation about these 2 modules (win32api, win32con)? It'd be very helpful, thankss. |
These days it's even better to do the following instead of relying on the active app:
where |
Since this is still open, and I just worked with it, I will add this link. You can use it as Felix's example above, except you do not need the win32con. Just use the hexadecimal number. WITHOUT the 'L' at the end, as you will see in the link.
I wanted an OK/Cancel window so I used the code below. If you assign a variable to it you will still get the window in Excel. Then the variable will be == 1 if it was OK, and == 2 if it was Cancel.
|
and in appscript: import xlwings as xw
from osax import OSAX
from appscript import k
# create an OSAX (Open Scripting Architecture Extension)) instance for StandardAdditions
# /System/Library/ScriptingAdditions/StandardAdditions.osax
sa = OSAX(pid=xw.apps.active.pid)
# bring current process to front so dialog box will be visible
sa.activate()
print(sa.display_alert('Hello World!', as_=k.critical))
```
See:
https://github.com/hhas/appscript/blob/master/py-appscript/sample/osax/standard_additions.py
and a legacy reference:
https://github.com/mattneub/appscript/blob/master/py-appscript/tags/py-appscript-0.16.2/Lib/osax/wrappers.py#L67-L86
* Google Apps Script:
```js
SpreadsheetApp.getUi().alert("hello")
|
I mean how to run the VBA function "MsgBox" in python, so that I can send something useful to users.
The text was updated successfully, but these errors were encountered: