Part B U2 Ch5
Part B U2 Ch5
PART B
UNIT – 2: ELECTRONIC SPREADSHEET (ADVANCED) USING LIBREOFFICE WRITER
CH – 5: USING MACROS
Introduction
Many times, we require to perform repeated tasks such as typing school name, address, contact numbers with
a specific formatting or apply the same formula at a particular cell for different sheets in a workbook
In this chapter, you will learn how to use a macro to automate repeated tasks that are always performed in the
same way over and over again.
Recording a Macro
A macro is a single instruction that executes a set of instructions. These set of instructions can be a sequence of
commands or keystrokes that can be used for any number of times later.
By default the macro recording feature is turned off when LibreOffice is installed on our computer.
Macro recording can be enabled by selecting Tools > Options > LibreOffice > Advanced. Observe the Optional
Features. There are two options which are not check marked. Put the checkmark on the option "Enable macro
recording"
1. Open the LibreOffice Basic Macro dialog box using Tools > Macros > Organize Macros > Basic
2. Click on Organizer.
3. From Modules tab, select My Macros folder and click on New button.
4. Give a name to the New Module say 'Hello' and click Ok.
5. Select Hello and click Edit to open the Integrated Development Environment (IDE).
6. Type Print "Hello" between Sub Main and End Sub.
7. Run the macro by clicking on Tools>Macro > Run Macro
NOTE: The module can be executed from the IDE by either clicking the Run button or pressing F5.
Macro as a Function
Suppose we need to perform the same calculation again and again on different sheets and there is no predefined
function for it. In such a situation it will be convenient to create a macro that performs the calculations. It will
save our effort of remembering and typing the formulas.
It is possible to do so if we use Macro as a function. Instead of writing instructions in between Sub and End
Sub, we can write instructions in between Function and End Function. A function is capable of accepting
arguments or values
BOOK SOLUTION
A. Multiple choice questions
1. Macro Recordings can be enabled from the option in the menu bar.
(a) Sheet (b) Data (c) Tools (d) Window.
2. Which of the following is valid Macro Name?
(a) 1formatword (b) format word (c) format*word (d) Format_word.
3. Which of the following Libraries contains modules with prerecorded macros and should not be changed?
(a) My Macros (b) LibreOffice Macros (c) Untitled1 (d) Test.
4. Identify which of the following is a programming Language?
(a) Calc (b) BASIC (c) Writer (d) Macro.
5. The Module can be executed from the IDE by pressing
(a) F3 (b) F4 (c) F5 (d) F6
6. Which of the following is the default name of the Macro
(a) Default (b) Main (c) Macro1 (d) Main_Macro
B. Fill in the blanks
1. Standard library is automatically loaded when the document is opened.
2. IDE stands for Integrated Development Environment.
3. Macro as a function is capable of accepting arguments and returning a value.
4. Macro organizer allows us to add, delete a module.
5. The code of macro begins with Sub followed by the name of the macro and ends with End Sub.
Part B Unit 2 Chapter 5
6. By default a macro is saved in the Standard Library.
C. State whether the following statements are True or False.
1. Macro is a group of instructions executing a single instruction. False
2. Once created, Macro can be used any number of times. True
3. By default, the Macro recording feature is turned on. False
4. It is not possible to stop recording of a Macro. False
5. Every Macro should be given a unique name. True
6. A macro once created can be edited later. True
D. Answer the following questions:
Q1. What is a Macro? List any two real life situations where they can be used.
Ans. A macro is a sequence of instructions or commands that automate repetitive tasks in software applications.
In other words we can say that a macro is a single instruction that executes a set of instructions.
Here are two real-life situations where macros can be used
1. Data Entry
2. Document Formatting
Q2. List the actions that are not recorded by a macro.
Ans. Actions that are not recorded by a macro are:
1. Opening of windows
2. Actions carried out in another window than where the recording was started.
3. Window switching
4. Actions that are not related to the spreadsheet contents.
5. Selections are recorded only if they are done by using the keyboard (cursor traveling), but not when the
mouse is used.
6. The macro recorder works only in Calc and Writer.
Q3. How is LibreOffice Macros Library Different from my Macros?
Ans.