Ask Your Question
1

How do I set a button to execute a macro in calc?

asked 2021-01-18 01:48:05 +0200

MikeMcClain46 gravatar image

I'd like a button in a cell to execute a macro but haven't been able to figure it out.

Can someone point me to a set of instructions, preferably like step 1, step 2 step 3.

Jumping back and forth between the OO basic, calc and API docs has me quite confused at the moment.

Thanks, Mike

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
2

answered 2021-02-28 06:20:47 +0200

Zizi64 gravatar image

updated 2021-02-28 06:30:38 +0200

I selected cell C1, which is where I want the button.

You can not put a graphical objects (like the form control elements) into a cell. The graphical objects are located on a graphical layer what is independent from the cells. But you can align the button to a cell visually, and you can anchor a button to a cell.

I did toggle edit mode and suspect I've got a button in the cell now, not sure. How do I access properties?

  • It is not enough to click on the Form control icon and on the Cell C1. You must "draw" a rectangle for the button on the graphical layer by dragging the mouse.
  • How to edit the Properties and Events of a button: Right click on the button - Control. Finally switch OFF the edit mode.
edit flag offensive delete link more
1

answered 2021-01-27 04:05:26 +0200

MikeMcClain46 gravatar image
newbie-02, I appreciate the help but I just needed more detail than you were supplying due to my own ignorance.

With what you gave me plus what these had to say, I finally got it done.
https://forum.openoffice.org/en/forum/viewtopic.php?f=9&t=104235
https://forum.openoffice.org/en/forum/viewtopic.php?f=9&t=55567 
http://www.openoffice.org/documentation/HOW_TO/various_topics/How_to_use_basic_macros.sxw

To make a button: 
        View>Toolbars>Form Controls
        Turn on design mode (button #2)
    Select PushButton on ToolBar, hover cursor over icons for description.
    In spread sheet, click/drag left mouse button to draw a button.
    Right click (middle for me) on button, select 'Control.
    This will bring up properties Dialog.
    Under 'General'
        Set 'Label', 
        Printable = No (do not print the button)
        Repeat = No
        Take Focus on Click = No
        Set color if you like
        Action = None
    Under 'Events', at the top of the dialog,
        'Mouse button released' click the box 
            then click the little box on the right [...]
            select 'Macro', then select the macro to run.
            Click 'OK'
        close the properties dialog
    Back to the 'Form Controls' Toolbar, click 'DesignMode', button 2 to leave design mode.
    close the Toolbar

    Turn off design mode, close the tool bar.

I'll leave this for the next tyro who asks this question.

Be well,
Mike
edit flag offensive delete link more

Comments

:-)
everyone works better in tasks where he had to invest some own effort,
happy that you got it running ...

newbie-02 gravatar imagenewbie-02 ( 2021-01-27 08:04:21 +0200 )edit
1

answered 2021-01-18 05:58:56 +0200

newbie-02 gravatar image

hello @MikeMcClain46,

  1. view - toolbars - form controls,
  2. add 'push button',
  3. edit it's properties and assign your macro somewhere at 'release button',
  4. you have to switch of form controls 'edit mode' to be able to use the button,
  5. some actions are difficult for buttons search for questions about 'taking focus' and follow advice there,

regards

b.

edit flag offensive delete link more

Comments

Hello newbie-02,

Pardon me for being so dense.

I selected cell C1, which is where I want the button.

view - toolbars - form controls, clicked 'push button', but see no change.

I tried dragging the button off the toolbar, doesn't work.

What am I missing?

Thanks, Mike

MikeMcClain46 gravatar imageMikeMcClain46 ( 2021-01-18 16:22:16 +0200 )edit

works for me, easiest fail: are the icons in the form control toolbar grey? then you first need to activate 'edit mode' there ...

newbie-02 gravatar imagenewbie-02 ( 2021-01-18 16:26:04 +0200 )edit

No they weren't grayed out. I did toggle edit mode and suspect I've got a button in the cell now, not sure. How do I access properties?

MikeMcClain46 gravatar imageMikeMcClain46 ( 2021-01-18 18:54:02 +0200 )edit

what about right click on the button (while in edit mode) - control properties - tab 'events' - mouse button released?
i'd never say such things are easy or 'intuitive' in calc, but it's a powerful system and after some learning and tolerating some oddities one can do a lot with it ...
b.t.w. 'solved marks and likes welcome' ... once it works ...

newbie-02 gravatar imagenewbie-02 ( 2021-01-19 02:39:00 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-01-18 01:48:05 +0200

Seen: 141 times

Last updated: Feb 28