Add a Button to Run Macro in LibreOffice Calc

Опубликовано: 15 Июль 2026
на канале: Office Nifty
12,459
147

Would you like help in using Calc?🧑‍💻
I have some slots this month to personally help my subscribers and viewers: https://cal.com/nifty

This video goes over adding a button to your sheet using Form Controls, and then changing the button's look and feel.
Next, we assign an existing macro for one of the button's event, so that it will run every time we click the button.
Importantly, I discuss macro security settings and how to prevent using them in untrusted files.
Lastly, I answer a viewer's question about using a button to recalculate random numbers. There's a very small chance that you can get rich using it. 😁

Using Checkboxes in Calc ☑
   • How to Add and Use a Checkbox in LibreOffi...  
Learn to create a macro in Calc ➰
   • Getting Started with Macros (Basic Example...  

Code for the two macros used:
Sub HelloMacro
Print "Hello"
End Sub

Sub RecalculateSheet
ThisComponent.calculateAll()
End Sub

Video Chapters
0:00 Add a button
1:20 Anchor to cell
2:22 Fit to cell size
2:38 Change label, font and colors
3:36 Link a macro
4:56 Macro security
6:17 Answering viewer question
6:54 Recalculate random numbers


#LibreOfficeCalc