Page 233 - Trackpad 402_Class-X_Final
P. 233
Step 6: Press Ctrl+S or click on Save to save the changes in the code window.
Step 7: Close the code window.
Step 8: Now type =Displaycontent() in cell B3. You will see the text “Macros are interesting” displayed automatically
in a cell as shown below:
Tick ( ) if you know this.
Macro helps you merge two or more different versions into one document.
The values written within the circular brackets of the function are called arguments.
Sorting means arranging the data in the ascending or descending order.
Passing Arguments to Functions created Using Macros
The values written within the circular brackets of the function are called arguments. These arguments are created to
pass as values to the functions.
Let us create a function to add two cells:
Function Addcells(a, b)
Addcells=a+b
End Function
In the above code a, b written within Addcells() are two arguments which are passed as values.
• Enter 10 in cell B3 and 20 in cell C3
• Type =Addcells(B3, C3)
• As soon as you press enter key you will see the total as 30
Accessing Cells Directly
You can access the OpenOffice internal objects directly to manipulate a Calc document. For example, the macro in
Listing 7 adds the values in cell A2 from every sheet in the current document. ThisComponent is set by StarBasic when
the macro starts to reference the current document. A Calc document contains sheets: ThisComponent.getSheets().
Use ion(col, row) to return a cell at a specific row and column getCellByPosition(col, row) to return a cell at a specific
row and column.
Electronic Spreadsheet (Advanced) 233

