0% found this document useful (0 votes)
12 views4 pages

Part B U2 Ch5

Class X IT 402: Part B Unit 2 Chapter 5

Uploaded by

fx48790
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Part B U2 Ch5

Class X IT 402: Part B Unit 2 Chapter 5

Uploaded by

fx48790
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Part B Unit 2 Chapter 5

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"

Following actions are not recorded in Macro


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. For example, changes made in the Options dialog,
macro organizer, customizing.
5. The macro recorder works only in Calc and Writer.
Steps given below to record a macro
1. Click on Tools > Macros and then click on the Record Macro.
2. Now start taking actions that will be recorded.
3. Click on "Stop Recording" button to stop the recording of actions.
4. Basic Macros dialog window open to save the Macro.
Part B Unit 2 Chapter 5
5. Select the object in the Save Macro to list box.
6. Type the name of the macro and click on Save button.
NOTE: By default the name of the macro is Main and is saved in the Standard Library in Module1. A Library is
a collection of modules which in turn is a collection of macros.
Rules for naming a Macro, Module or a Library:
While naming a Macro, Module or a Library the name should:
1. Begin with a letter
2. Not contain spaces
3. Not contain special characters except for (underscore)
Running a Macro
To run a macro we need to perform the following steps.
1. Click Tools > Macros > Run Macro
2. Macro Selector dialog box will open.
3. Select the library that contains the macro then select the macro under 'Macro name'.
4. Click on Run to run the macro.
Code of a Macro
The action recorded by a macro is recorded as instructions in a programming language called BASIC. It is also
possible to view and thus edit the code of a macro. But remember, it is advised to edit a macro only if you have
knowledge of the language.
We can view the code generated for the macros by going to Tools > Macros > Edit Macros. Choose the macro
name from the Object Catalog and the associated code will be visible.
NOTE: The code of a macro begins with Sub followed by the name of the macro and ends with End Sub. Do
not make any changes to the code unless you are aware of the language.

Creating and Organising a Simple Macro


Steps to organize the macro.
1. Click on Tools > Macros > Organize Macros > Basic
2. Basic Macro Dialog window open.
3. Click Organizer to open the Basic Macro Organizer dialog.
4. Click on Library > New to create library to store macro.
5. Click on Module tab and then New to create Module to store macro.
Part B Unit 2 Chapter 5
Create a simple Macro using BASIC programming instructions that will display Hello in a dialog box stored in
the Standard module.

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.

Q4. Differentiate between predefined function in Calc and Macros as a function.


Ans.

Q6. Give any one advantage of macros.


Ans. Macros automate repetitive tasks, saving time and increase efficiency and consistency.

You might also like