Ch 5: Using Macros
What is a Macro?
Enabling & Recording a Macro
- Enable: Tools > Options > LibreOffice > Advanced > tick Enable macro recording (off by default).
- Tools > Macros > Record Macro.
- Perform the actions to be recorded.
- Click Stop Recording.
- In the Basic Macros dialog, choose the Library/Module, type a macro name and click Save.
Running a Macro
Tools > Macros > Run Macro > expand the Library and Module > select the macro > Run.
Library, Module and Macro
Two containers appear: LibreOffice Macros (pre-recorded — do not change) and My Macros (macros the user writes/adds).
Macro written in BASIC
Macros are written in the BASIC language. Code begins with Sub <name> and ends with End Sub. Edit via Tools > Macros > Edit Macros (the IDE opens; run with F5).
_).Macro as a Function
Instead of Sub … End Sub, use Function … End Function. A function accepts arguments, performs a calculation and returns a result — useful for repeated custom calculations (e.g. tiles needed for a floor). Call it in a cell like a built-in function.
Summary
- A macro automates repeated tasks; recording must be enabled first.
- Library > Module > Macro. Code:
Sub … End Sub, written in BASIC. - Names: start with a letter, no spaces, only
_allowed as a special character. - A macro-as-function returns a value and can be used inside a cell.
Quick check: 3 MCQs (tap an option)
Q1. Macros in LibreOffice are written in the language:
Code starts with Sub name and ends with End Sub.
Q2. A Library is a collection of:
Library → Modules → Macros.
Q3. Which action is NOT recorded by the macro recorder?
Only keyboard selections are recorded.
Macro क्या है?
Macro Enable और Record करना
- Enable: Tools > Options > LibreOffice > Advanced > Enable macro recording tick कीजिए (default off)।
- Tools > Macros > Record Macro.
- Record करने वाली actions कीजिए।
- Stop Recording पर click कीजिए।
- Basic Macros dialog में Library/Module चुनकर macro नाम देकर Save कीजिए।
Macro चलाना
Tools > Macros > Run Macro > Library और Module expand कीजिए > macro चुनिए > Run।
Library, Module और Macro
दो containers दिखते हैं: LibreOffice Macros (pre-recorded — मत बदलिए) और My Macros (user के लिखे/जोड़े macros)।
BASIC में लिखा Macro
Macros BASIC भाषा में लिखे जाते हैं। Code Sub <name> से शुरू और End Sub पर ख़त्म होता है। Edit: Tools > Macros > Edit Macros (IDE खुलता है; F5 से run)।
_) के अलावा कोई special character नहीं।Function के रूप में Macro
Sub … End Sub के बजाय Function … End Function इस्तेमाल कीजिए। Function arguments लेता है, गणना करता है और result लौटाता है — बार-बार होने वाली custom गणनाओं को उपयोगी (जैसे floor के लिए tiles)। इसे cell में built-in function की तरह call कीजिए।
सारांश
- Macro बार-बार होने वाले काम automate करता है; पहले recording enable करनी होती है।
- Library > Module > Macro। Code:
Sub … End Sub, BASIC में। - Names: letter से शुरू, कोई space नहीं, सिर्फ़
_special character allowed। - Function वाला macro value लौटाता है और cell में इस्तेमाल हो सकता है।
झटपट जाँच: 3 MCQs (option पर tap करें)
Q1. LibreOffice में macros किस भाषा में लिखे जाते हैं?
Code Sub name से शुरू होकर End Sub पर ख़त्म होता है।
Q2. Library किसका संग्रह है?
Library → Modules → Macros।
Q3. Macro recorder कौन सी action record नहीं करता?
सिर्फ़ keyboard वाले selections record होते हैं।
Frequently Asked Questions
What is a macro in LibreOffice?
A macro is a single instruction that runs a whole set of recorded commands or keystrokes. It automates repeated tasks so they can be run any number of times with one click.
In which applications does the macro recorder work?
The macro recorder works only in LibreOffice Calc and Writer. Actions like opening windows or mouse selections are not recorded.
What is the relationship between a library, a module and a macro?
A library is a collection of modules, and a module is a collection of macros. The default macro Main is stored in the Standard library, Module1.
What are the naming rules for a macro?
A macro name must begin with a letter, must not contain spaces, and cannot use special characters except the underscore (_).
