Forum Discussion
Excel for Web: Control equivalent to the VBA messagebox
Perhaps you should file an idea here: https://feedbackportal.microsoft.com/feedback/search/c23f3b77-f01b-ec11-b6e7-0022481f8472?q=script
- bottaxxgpJan 10, 2024Copper Contributormtarler good solution.
I cannot create button programmatically linked to a script but i can create some sheet only for show the message and pre-create the button with the Ok button to close the "message sheet"
The only problem is that if the user forget to press Ok, i leave a "message sheet" visible.....
In any case, it's a next step towards a type of pop up that I wasn't able to imagine before.
I could also hide all the other sheets present and leave only the current message sheet, forcing the user to do the only thing possible in that sheet. Press the OK button- mtarlerJan 10, 2024Silver Contributoryes and in addition to hiding the other sheets I would also lock the workbook to prevent them from doing anything else or try deleting the sheet or what not...
- bottaxxgpJan 18, 2024Copper Contributor
I created a sheet with some shape to simulate a Msgbox.
I added manually and Excel assign some default names to these shapesI created a simple macro that show the real name of the shape assigned form Excel and the text inside in each shapes.
In this way we can identify the index of every shapes and , activating the edit part of the macro, assign a useful name to every shapes.
I assigned titolo and messaggio to the shapes that will contain the text of the msgbox.
The buttons don't necessarily need a name because I assigned 3 specific macros to them.
I defined a functionfunction msgboxShow(msgBoxTyp: msgBoxType, title: string, message: string, wb: ExcelScript.Workbook, shName: String, msgType: String, par1: string ="", par2 : string="")
- msgBoxTyp ( one of the possibile msgbox define in an enum, showed below)- title - A string with the title of the msgbox- message - A string with the message of the msgbox- wb - the workbook- sh - the worksheet that call the msgbox- msgType - A string that identify the action to perform- par1, par2 some optional parameters for future use
This function Unhide the Msgbox worksheet and write in some defined cells (covered by the shape) where i write the parameter of the Msgbox.enum msgBoxType { msgboxOk, msgboxSiNoCancel }
The big problem is that isn't possible call one function from another macro, than i have to copy this function in every macro that need a MsgBox
Another big problem is that the execution of a macro from a button pressing is always very very slow.
A macro that need 1 second to run, have to wait :
- the initialization of the button (5 seconds more or less)
- the preparation of the button (5-10 seconds more or less)
- the execution of the macro