Pop-up for: Do you really want to?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
jimbokea2
Posts: 11
Joined: Thu Jul 03, 2025 11:03 pm

Pop-up for: Do you really want to?

Post by jimbokea2 »

Hi There
Is there a facility attached to "buttons" that has a pop-up that asks if you really want to do whatever the button does?
I have a macro attached to a button in a spreadsheet set that does about 7 different things if clicked. It is only clicked if what it does is required but I have had people click on it accidentally and they don't know how to reverse what they just did
Cheers Jim
Last edited by MrProgrammer on Wed Aug 13, 2025 2:15 am, edited 1 time in total.
Reason: Edited topic's subject
OpenOffice 4.1.13
User avatar
robleyd
Moderator
Posts: 5429
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: DO YOU REALLY WANT TO POP UP

Post by robleyd »

A message box is one solution - MsgBox in the Wiki
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 25.8.1.1; SlackBuild for 25.8.1 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue]
Unexpected '{' on line 32
.
jimbokea2
Posts: 11
Joined: Thu Jul 03, 2025 11:03 pm

Re: Pop-up for: Do you really want to?

Post by jimbokea2 »

Where do I find this MsgBox in the calc
OpenOffice 4.1.13
User avatar
robleyd
Moderator
Posts: 5429
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Pop-up for: Do you really want to?

Post by robleyd »

It isn't "in the Calc"; you need to script it as part of the macro. The link I gave above has an example very similar to what you want. You would probably put the message box as the first thing in the macro, depending on exactly what the macro does.
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 25.8.1.1; SlackBuild for 25.8.1 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue]
Unexpected '{' on line 32
.
jimbokea2
Posts: 11
Joined: Thu Jul 03, 2025 11:03 pm

Re: Pop-up for: Do you really want to?

Post by jimbokea2 »

OK, I will try it out
OpenOffice 4.1.13
jimbokea2
Posts: 11
Joined: Thu Jul 03, 2025 11:03 pm

Re: Pop-up for: Do you really want to?

Post by jimbokea2 »

Not sure what you actually mean by "script it as part of the macro"
To make the macro I go to tools - macros - record macro and do the sorting and other things then stop recording and give it a name.
I then assign that macro to a push button.
I cannot see where or when I can introduce MsgBox
Jim
OpenOffice 4.1.13
User avatar
robleyd
Moderator
Posts: 5429
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Pop-up for: Do you really want to?

Post by robleyd »

You have to edit the macro and add the relevant code.

Tools | Macros | Organise Macros | OpenOffice Basic; assuming that is where you saved your recorded macro. Then select the macro and use the Edit button to edit it.
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 25.8.1.1; SlackBuild for 25.8.1 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue]
Unexpected '{' on line 32
.
User avatar
RoryOF
Moderator
Posts: 35095
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Pop-up for: Do you really want to?

Post by RoryOF »

@jimbokea2: you would be well advised to read the programming guide to OpenOffice BASIC at
https://wiki.openoffice.org/wiki/Docume ... ASIC_Guide

This will give you an understanding of the code the record macro facility is providing and aid your modification of it.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
jimbokea2
Posts: 11
Joined: Thu Jul 03, 2025 11:03 pm

Re: Pop-up for: Do you really want to?

Post by jimbokea2 »

Sorry - a bit beyond me
OpenOffice 4.1.13
Bidouille
Volunteer
Posts: 648
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: Pop-up for: Do you really want to?

Post by Bidouille »

Where is your difficulty?

Code: Select all

Sub Message
	iRet = MsgBox("Should I continue?", 4, "Confirm")
	if iRet = 6 then
		'Press Yes...
	else
		'Press No...
	endif
End Sub
Assign this sub to the control execute action event.

Otherwise I suggest you post a stripped down version of the document (with sensitive information removed) for people to look at.
User avatar
Lupp
Volunteer
Posts: 3710
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Pop-up for: Do you really want to?

Post by Lupp »

(@Bidouille; You sure you don't mix up "MsgBox" and "InputBox"?)

@jimbokea2:
See attached example:
recordedsort.ods
(14.84 KiB) Downloaded 4 times
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
MrProgrammer
Moderator
Posts: 5322
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Pop-up for: Do you really want to?

Post by MrProgrammer »

Lupp wrote: Thu Aug 28, 2025 11:00 pm You sure you don't mix up "MsgBox" and "InputBox"?
MsgBox Function: Displays a dialog box containing a message and returns a value
Syntax:          MsgBox (Text As String [,Type As Integer [,Dialogtitle As String]])
Text:            String expression displayed as a message in dialog box
Type:            Specifies buttons or icons displayed
                    Displayed buttons                       +   Icon           +    Default button
                 0: OK                                      16: Stop           128: First 
                 1: OK Cancel                               32: Question       256: Second
                 2:           Abort Retry Ignore            48: Exclamation    512: Third
                 3:    Cancel                    Yes No     64: Information
                 4:                              Yes No
                 5:    Cancel       Retry
DialogTitle:     String expression displayed in title bar of dialog
                 If omitted, name of application is displayed
Return type:     Integer
Return value:    1: OK, 2: Cancel, 3: Abort, 4: Retry, 5: Ignore, 6: Yes, 7: No
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
Lupp
Volunteer
Posts: 3710
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Pop-up for: Do you really want to?

Post by Lupp »

Sorry and thanks!
I once knew this, but used MsgBox() with only the first argument for a long time now.
Forgot about that functionality.
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply