Calc Guide

Figure 314: Basic Integrated Development Environment (IDE)
7) Modify the code so that it is the same as that shown in Listing 2.The important
addition is the creation of the NumberFive function, which returns the number
five. The Option Explicit statement forces all variables to be declared before
they are used. If Option Explicit is omitted, variables are automatically defined
at first use as type Variant.
8) Save the modified Module1.
Listing 2. Function that returns five.
REM ***** BASIC *****
Option Explicit
Sub Main
End Sub
Function NumberFive()
NumberFive = 5
End Function
Using a macro as a function
Using the newly created Calc document CalcTestMacros.ods, enter the formula
=NumberFive() (see Figure 315). Calc finds the macro and calls it.
Chapter 12 Calc Macros 305