Reference: Using macros

There are three types of macros: Quattro Pro native macros, PerfectScript macros, and Visual Basic for Applications (VBA) macros. It is important to understand all three types of macros before choosing a macro that best suits your needs. Some aspects that you can look at are the differences between the macros and the syntax of a macro.


Additional macro resources

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

For more information about PerfectScript macros, see the PerfectScript Help (psh.chm) or the “Corel WordPerfect Office X5 User Guide for PerfectScript” (ps_ug.pdf).

For more information about using VBA with Quattro Pro, see the “Corel WordPerfect Office X5 User Guide for VBA” (vba_ug.pdf).

Certain editions of WordPerfect Office X5 include the WordPerfect Office Software Developer’s Kit (SDK), a set of tools that lets software developers customize WordPerfect Office applications for commercial or business use.


Choosing a tool for creating macros

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

Quattro Pro provides several built-in scripting tools to create macros:

 
Quattro Pro macros are stored in notebook cells. Use this type of macro when a task is performed within Quattro Pro.
 
PerfectScript macros are stored in a .wcm file. This type of macro is useful when you want to automate tasks with several notebooks or interact with other WordPerfect Office applications, such as WordPerfect. For example, you can update Quattro Pro data in a WordPerfect report. For information about using PerfectScript macros in Quattro Pro, see “Recording and editing PerfectScript macros.”
 
Visual Basic for Applications (VBA) lets you develop scripts that are saved within specific projects using a robust version of the Visual Basic programming language. You can access the VBA Editor from within Quattro Pro. For information about using VBA with Quattro Pro, see “Integrating Visual Basic for Applications with Corel WordPerfect Office.”

The simplest way to create a macro is to record the keystrokes in Quattro Pro. You can also write a macro to include non-recordable tasks. For example, you can define a macro to play until a certain event happens or include a comment to prompt users to enter specific data.


Comparing Quattro Pro macros with PerfectScript

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

Quattro Pro macros and PerfectScript use similar command syntax. There are, however, some major differences in the two scripting tools:

Quattro Pro macros
PerfectScript macros
Are stored in notebooks or cells
Are stored in .wcm macro files
Are created and edited in the notebook
Are created and edited in WordPerfect
Can be played from a library notebook
Are played from the source folder
Can use shortcut names for playing
Cannot play from shortcut names
Play only in Quattro Pro
Play in any WordPerfect Office application
Use blank lines to separate macros
Use blank lines to separate commands and subroutines
Use commands and arguments
Use commands and parameters (which contain arguments)

The following table presents the major syntactical differences between both macro tools:

Quattro Pro syntax
PerfectScript syntax
Command has curly braces
No braces around command
No parentheses around argument list
Parentheses required around parameter list
Object and property separated by period
Object and property separated by underscore
Arguments separated by commas
Arguments separated by semicolons

Examples of syntax in Quattro Pro macros

Quattro Pro macro syntax uses the following syntax format:

  {CONTENTS E15, F15, G15}   

The command name CONTENTS is the exact name of the command. Arguments are values providing instructions to the command. Not all macro commands require arguments, but when they do, they require specific information. For example, {BEEP} is a macro command without arguments. Many command equivalents contain a period (.) in their command name , for example {Search.Find "3rd Quarter Profits}.

PerfectScript uses the following syntax format:

  GraphGallery(GraphStyle:"3dbar";ColorScheme:"Tangerine")   

The command name GraphGallery indicates the feature the command activates. This particular example launches the Chart Gallery and selects a 3D bar chart with a tangerine color scheme. Some commands are made up of only a command name, such as FileOpenDlg(). Parameters provide more information about the command, such as which options of a feature are active. Parameters are always enclosed in parentheses; for example, Backup(State:On!). A semicolon is the separator mark between parameters in a command.

For more information about Quattro Pro syntax, see “Macro syntax and arguments.”

To get more information about recording and attaching macros to toolbars, notebooks, and controls, see “Using macros.”


Understanding Quattro Pro macro syntax

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

Macro commands are like spreadsheet functions: they have specific grammatical rules, or syntax. The basic syntax is

  {COMMANDNAME Argument1,Argument2, Argument3,...}   

COMMANDNAME is the name of the command.

Arguments are values. Not all macro commands require arguments; when they do, they require a specific type of information.

The following are some examples of macro commands:

  {Query.Criteria_Table B27..B29}   {BlockCopy A1,A2..A37}   {Search.Find "3rd Quarter Profits"}   {GETNUMBER "How old are you?",AGE}   {CONTENTS E15,F15,5}   

Quattro Pro syntax requires that you type the entire macro command in a single cell. The following syntax rules for macro commands also apply:

QP syntax must include
Examples
Opening and closing braces{} 
{BEEP 3}
COMMANDNAME(space)Argument1
{BlockCopy A1}
Commas or semicolons between arguments
{CONTENTS E15,F15,5}
Correct argument types
{GETLABEL hello world, A4} where “hello world” is not a valid string type
Quotation marks around punctuation or spaces
{GETLABEL “Hello,world”,A4}
Type command in upper/lower case
GETLABEL = getlabel
One or more commands for each cell
{BEEP}{GETLABEL “Hello, world”,A4}{QUIT}

If a setting contains spaces, punctuation, or quotation marks, enclose it within double quotation marks (for example, “Prefix, “”Windows Default”",”,No”).


Understanding arguments

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

Arguments in macro commands, like those used with spreadsheet functions, require specific information to be supplied with the command. There are four types of arguments: numbers, strings, locations, and conditions.

Number arguments
Examples
Any numeric value, entered as a number
2 or 0.45
A formula resulting in a number
A3*15
A cell address with a numeric value or formula
C10, where C10 contains a number or formula
A named block with a numeric value or formula
C10, where C10 contains a valid number or formula
String arguments
Examples
A text string, such as an actual string
“Corel”
A reference to a cell or block containing a label
A1..A4
A property separated by a comma (,)
“Currency, 2″ (This also applies to command settings separated by a comma)
A formula resulting in a label
@UPPER(“hello “)

Location arguments
Examples
A block name
INTEREST refers to a cell block C5-C15
Block coordinates with more than one cell
A1,A1..A4 or A..B:C4..D22
A block relative reference of more than one cell
[]C(0)R(0),[]P(-2):C(0)R(22) or []C(0)R(0)..C(3)R(10)
Coordinates for noncontiguous blocks
(A1,B1..B7,C1..C7) or (A1,B:C27..C52)
A label or text formula in any of these options
+”A”&”2″ which results in A2

Condition arguments
Examples
A formula that evaluates to true or false
+C4>500

Some commands accept a combination or choice of argument types. For example, {LET} stores either a label or a number in a cell, depending on the argument type.

You can use argument suffixes in a command to specify a value or label entry. Using :string (or :s) assures a label entry, and :value (:v) ensures a value entry (if the entry is a valid number). In the following example, the first example enters the value 7 into a new_block, while the second example enters a label into a new_block:

  {LET new_block,3+4:value}   {LET new_block,3+4:string}   

For information about PerfectScript syntax, see “Choosing a tool for creating macros.”

For information about using relative cell references, see “Recording macros that use relative or absolute cell references.”


Integrating Visual Basic for Applications with Corel WordPerfect Office

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

You can use Microsoft Visual Basic for Applications (VBA) with WordPerfect Office. VBA is an object-oriented programming language that lets you create VBA macros to automate tasks. You can, for example, create a macro in WordPerfect that changes the color of headings in a spreadsheet. VBA is not part of the typical install of WordPerfect Office. To use VBA, you should do a custom install and enable Microsoft Visual Basic for Applications.


Event-driven programming

Visual Basic for Applications is an event-driven programming language. Most of the code you create is written to respond to an event. An event is an action recognized by VBA; for example, clicking a button or choosing an option from a list box. Unlike traditional procedural programming, in which the program starts at line 1 and executes line by line, event-driven programming executes code in response to events.


The difference between PerfectScript and VBA

Previously, you could use the PerfectScript language only to automate specific tasks. Both product commands and programming commands are used in conjunction with the PerfectScript language. The PerfectScript language is useful for developing simple macros. VBA offers more flexibility and power. When you use VBA to create macros, you are assisted by the Visual Basic compiler. The compiler helps you by providing context-sensitive help when you are coding a VBA macro. You can combine the power of VBA with the PerfectScript product commands to create powerful macros. You have to use the Visual Basic Editor to create VBA macros; however, PerfectScript macros are developed from the WordPerfect Editor. You can access the Visual Basic Editor only when you are working in an active document.


The PerfectScript class

All product commands used in WordPerfect, Quattro Pro, and Presentations can be used in VBA macros. You must call the PerfectScript object to access a product command. An object is an instance of a class. All objects have properties; for example, the name of a document is a property that belongs to the document object. You can set or change an object’s properties by calling certain methods. A method performs a specific action, such as inserting a table into a document. You can, for example, close a document by calling the close method, or you can save a document by calling the save method. The term class is a VBA programming term and means a collection of related methods, which are referred to as class members. The product commands are the class members that belong to the PerfectScript class. WordPerfect, Quattro Pro, and Presentations have their own PerfectScript class because the class members, which are the product commands, are different depending on the application.

All members of the PerfectScript class perform a specific action. For more information about product commands, see the macros command list “QP MACRO LIST”.

Wordperfect Quattro Pro note Reference: Using macros

 
Although there may be some differences, the syntax for the product commands and the PerfectScript members is usually the same.


Working in the VBA Editor

In most cases, the name of the class is the same as the name of the object. WordPerfect Office has a document object. The document object is the host application that is open. In Quattro Pro, the name of the document object is ThisNotebook. In WordPerfect, the name of the document object is ThisDocument. In Presentations, the name of the document object is ThisSlideShow.

You can create a new object, such as a dialog box, which is known as a form. You can add controls, such as a check box or a text box. You can set the object’s properties in the property dialog box locat
ed in the Visual Basic Editor. You can also set the object’s properties at run time by programming a method. For example, you can color a form red when you click on it. For more information about setting an object’s properties, see the Microsoft Visual Basic Help in the Visual Basic Editor.

An experienced programmer can work directly with the Windows API (Application Programming Interface) and, for example, be able to determine how much disk space is available or gain access to the system’s time and date values. Most VBA users will want to automate specific and repetitive tasks.

Accessing an application from another application’s macro

You can access and change an application from another application’s macro. For example, you can create and use a Quattro Pro object from a WordPerfect VBA macro. This allows you to change and save a Quattro Pro document from a WordPerfect VBA macro.


Using VBA macros

You can store a VBA macro in the document by saving the document. Once you have saved the document, you can close and reopen the document and access the macro. After you have developed the macro, you should debug it. You can step through each macro line by line. This is a useful exercise to ensure that the macro will have the desired outcome. A project macro is not available if the document is closed. After you have debugged the macro, you can play the macro.


Assigning security

When you open WordPerfect Office documents created by other users, be aware that a document could contain a macro virus. As a screening measure, VBA includes a security mechanism to help manage document security. You determine the security level used when opening or loading documents and add-ins containing embedded VBA macros. The Security dialog box lets you review the assigned security level and your collection of trusted certificates. You can trust a certificate that you know comes from a reputable source. VBA developers can attach their digital signature to a macro that creates a certificate when the document is opened. That a document has a digital signature does not automatically ensure the document is free of viruses, so the onus is on you to find out if the developers scans for viruses before adding their certificate to your trusted sources.

There are three security level settings available: High, Medium and Low. With the High setting, you can open a signed VBA project from a trusted source with the macros enabled. Otherwise, the document is opened with the macros disabled. The default security setting is Medium. A Medium setting indicates that a warning displays if you try to load a VBA document that is not on your trusted source list. You can then choose to open the document with the macros enabled or disabled. The Low setting allows you to open all VBA projects without applying any security (which disables all virus protection).

If you want to create your own certificate (in situations where you do not have formal certification), you can run the seflcert.exe that installs with Visual Basic for Applications. For more information about Visual Basic for Applications security, open the Security dialog box (click Tools Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Wordperfect Quattro Pro onestep Reference: Using macros Security) and click the What’s this Help.


Setting macro breakpoints

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

The following macro includes a loop that continuously increments a single cell called COUNTER.

  counter  0   Is_done +COUNTER>=100   \m {LET counter,0}   again {; increment counter}   {LET counter,counter+1}~   {BRANCH again}   

A pass count specifies the number of loops that occur before reaching a breakpoint. If you specify the cell containing {BRANCH again} as the first breakpoint and leave the pass count at 1, the macro stops at the {BRANCH} command each time it goes through the loop. When you click Go, the macro continues, incrementing the counter cell by one. In the top of the debugger window, the selector highlights the {BRANCH} command, indicating that it is the next command.

If you specified a pass count of 5 for the first breakpoint in the above example, then every time you click Go, five loops occur, and the counter increments from 0 to 5, to 10, and so on.

The cell Is_done contains a logical formula. Is_done is false (has a value of 0) until 100 or more loops occur. If this cell is specified as a conditional cell, the macro pauses when the counter reaches 100.


Example of a VBA project macro in Quattro Pro

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros
1.
 
Click Tools Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Editor.
2.
 
In the Project Docker window double-click VBAProject (NoteBk) in the list of categories.
3.
 
Click Insert Wordperfect Quattro Pro onestep Reference: Using macros User form.
4.
 
Modify the form so that it resembles the following diagram:

Wordperfect Quattro Pro  Reference: Using macros tent/uploads/sub/quattro-pro/en/source/images/vba2.jpg" height="132" width="312" border="0" hspace="0" vspace="0">
5.
 
Change the name of the TextBox control to NameBox as illustrated in the following list:
Command Button — CommandButton1
TextBox — NameBox
6.
 
Double-click the CommandButton1 control to create a new method for the UserForm1 class, and type the following lines of code in the CommandButton1_Click method:
Private Sub CommandButton1_Click()
Dim myname, Msg As String
myname = NameBox
Msg = "Hello " & myname
MsgBox Msg
End
End Sub
This code responds to the event that occurs when the command button is clicked.
7.
 
Open the Quattro Pro objects folder in the Project Docker window.
8.
 
Double-click ThisNotebook.
9.
 
Type the following lines of code in the Notebk1 editor window:
Public Sub ShowForm()
End Sub
This code will add a new method to the ThisDocument class.
10.
 
Type the following line of code in the ShowForm method:
Public Sub ShowForm()
UserForm1.Show
End Sub

Wordperfect Quattro Pro note Reference: Using macros

 
If you declare ShowForm as a private method, you will not be able to run the macro from Quattro Pro.

Wordperfect Quattro Pro tip Reference: Using macros

 
You can change all of the control’s attributes, including the name of the control, in the Properties docker window.

Example of a VBA macro that manipulates a Quattro Pro document

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

In the following procedure, a Quattro Pro object, called myQp, will be created. This object will be used to create an inventory table in a Quattro Pro document.

For the purpose of this procedure, a simple inventory table was created in a Quattro Pro document. You can run this macro from WordPerfect. For testing purposes, make sure that Quattro Pro is open. For more information about VBA, see Microsoft Visual Basic Help in the Visual Basic Editor.

1.
 
Open WordPerfect.
2.
 
Click Tools Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Editor.
3.
 
Double-click on Project (Document1) in the Project explorer Docker window.
4.
 
Click Tools Wordperfect Quattro Pro onestep Reference: Using macros Reference.
5.
 
Enable the Corel — QuattroPro type library check box.
6.
 
Click OK.
7.
 
Open the WordPerfect objects folder in the Project explorer Docker window.
8.
 
Double-click ThisDocument, and type the following line of code in the code module window:
Public Sub CreateQPTable()
End Sub
This code adds a new method to the ThisDocument class.
9.
 
Type the following lines of code in the CreateQPTable method:
Public Sub CreateQPTable()
Dim myQp as Object
Set myQp = CreateObject("QuattroPro.PerfectScript")
If myQp Is Nothing Then
MsgBox "The Quattro Pro Object is invalid", vbCritical
End If
This code creates a Quattro Pro PerfectScript object. After the object is created, it is tested to determine if memory has been allocated to it. A message informs you if the object is invalid.
10.
 
Type the following lines of code in the CreateQPTable method:
Public Sub CreateQPTable()
Dim myQp as Object
Set myQp = CreateObject("QuattroPro.PerfectScript")
If myQp Is Nothing Then
MsgBox "The Quattro Pro Object does not exist", vbCritical
End If
'Populate the Quattro Pro document
myQp.FileNew "FileNew"
myQp.SetCellString "B1", "Jan"
myQp.SetCellString "C1", "Feb"
myQp.SetCellString "D1", "Mar"
myQp.SetCellString "A2", "TVs"
myQp.SetCellString "A3", "VCRs"
myQp.SetCellString "A4", "Radios
End Sub
This code creates a new Quattro Pro document and creates an inventory table.

Wordperfect Quattro Pro note Reference: Using macros

 
Make sure that CreateQPTable is declared public so that you can access this macro from WordPerfect.
 
Every application has an object. Make sure you reference the right object.

Example of using the PerfectScript class to change a Quattro Pro document

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

The PerfectScript class lets you automate specific and repetitive tasks. The members of the PerfectScript class are the product commands used in conjunction with the PerfectScript language. The following example creates a project macro.

In the following procedure, a new method, called AddInventory, is added to the ThisDocument class. This macro creates an inventory table, populates the table with specific values, and calculates the values. All PerfectScript class members can be accessed only by calling the PerfectScript object, which must be followed by a “.“. You can call the FileSave method, which is a PerfectScript class member, by typing: “PerfectScript.FileSave“.

1.
 
Click Tools Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Editor.
2.
 
In the Project explorer Docker window, double-click VBAProject (NoteBk1) Wordperfect Quattro Pro onestep Reference: Using macros Quattro Pro objects Wordperfect Quattro Pro onestep Reference: Using macros ThisNotebook in the list of categories.
3.
 
Type the following lines of code in the Notebook1 code module window:
Public Sub AddInventory()
End Sub
This code adds a new method, called AddInventory, to the ThisDocument class.
4.
 
Type the following lines of code to create a private method called CreateTable:
Private Sub CreateTable()
PerfectScript.SetCellString "B1", "Jan"
PerfectScript.SetCellString "C1", "Feb"
PerfectScript.SetCellString "D1", "Mar"
PerfectScript.SetCellString "A2", "TVs"
PerfectScript.SetCellString "A3", "VCRs"
PerfectScript.SetCellString "A4", "Radios"
End Sub
This code creates an inventory table.
5.
 
Type the following lines of code to create a private method called AddValues:
Private Sub AddValues()
'Populate the January Column
PerfectScript.SelectBlock "B2"
PerfectScript.PutCell2 "200"
PerfectScript.SelectBlock "B3"
PerfectScript.PutCell2 "250"
PerfectScript.SelectBlock "B4"
PerfectScript.PutCell2 "350"
'Populate the February Column
PerfectScript.SelectBlock "C2"
PerfectScript.PutCell2 "100"
PerfectScript.SelectBlock "C3"
PerfectScript.PutCell2 "280"
PerfectScript.SelectBlock "C4"
PerfectScript.PutCell2 "340"
'Populate the March Column
PerfectScript.SelectBlock "D2"
PerfectScript.PutCell2 "150"
PerfectScript.SelectBlock "D3"
PerfectScript.PutCell2 "230"
PerfectScript.SelectBlock "D4"
PerfectScript.PutCell2 "490"
End Sub
This code adds numeric values to the inventory table.
6.
 
Type the following lines of code to create a private method called CalculateValues:
Private Sub CalculateValues()
'Calculate the January totals
PerfectScript.SelectBlock "B2..B4"
PerfectScript.QuickFunction "SUM", "B5"
'Calculate the February totals
PerfectScript.SelectBlock "C2..C4"
PerfectScript.QuickFunction "SUM", "C5"
'Calculate the March totals
PerfectScript.SelectBlock "D2..D4"
PerfectScript.QuickFunction "SUM", "D5"
PerfectScript.SetCellString "A5", "Totals:"
End Sub
This code adds the values in each column.
7.
 
Type the following lines of code in the AddInventory method to call the private methods:
Public Sub AddInventory()
CreateTable
AddValues
CalculateValues
End Sub
This code calls all of the private methods that you created.

Wordperfect Quattro Pro note Reference: Using macros

 
If you declare AddInventory as a private method, you will not be able to run it from Quattro Pro.
 
You can access the private methods because you are working in the same class. It is not possible to access a private method from outside of the ThisDocument class.

Example of accessing the system’s date and time values

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

In the following procedure, you have to create a new method called, ShowTime. Next, you will declare two new variables: myTime and myDate. You can use the return value of the Time method to populate the myTime variable. The variable myDate can be populated by the return value of the Date method. You will have to type-cast the two variablesmyTime and myDateinto string values. The easiest way to accomplish this is to declare two new string variables: myStrDate and myStrTime. Use the Str method to convert the contents of myDate and myTime into strings. Display the contents of myStrDate and myStrTime in a Message Box.

The following example creates a project macro.

1.
 
Click Tools Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Wordperfect Quattro Pro onestep Reference: Using macros Visual Basic Editor.
2.
 
In the Project explorer Docker window, double-click VBAProject (NoteBk1) Wordperfect Quattro Pro onestep Reference: Using macros Quattro Pro objects Wordperfect Quattro Pro onestep Reference: Using macros ThisNotebook in the list of categories.
3.
 
Type the following lines of code in the Notebook1 code module window:
Public Sub ShowTime()
End Sub
This code will add a new method to the ThisDocument class.
4.
 
Type the following new code in the ShowTime method to declare two new variables:
Public Sub ShowTime()
Dim myTime
Dim myDate As Date
End Sub
5.
 
Type the following new code in the ShowTime method to populate the myTime and the myDate variables:
Public Sub ShowTime()
Dim myTime
Dim myDate As Date
myTime = Time
myDate = Date
End Sub
6.
 
Type the following new code in the ShowTime method to convert the two variables to string data types:
Public Sub ShowTime()
Dim myTime
Dim myDate As Date
myTime = Time
myDate = Date
Dim myStrTime, myStrDate, Msg As String
myStrDate = Str(myDate)
myStrTime = Str(myTime)
End Sub
7.
 
Type the following new code in the ShowTime method to populate and display the Msg variable:
Public Sub ShowTime()
Dim myTime
Dim myDate As Date
myTime = Time
myDate = Date
Dim myStrTime, myStrDate, Msg As String
myStrDate = Str(myDate)
myStrTime = Str(myTime) 
Msg = "The date is " & myStrDate & " and the time is " & myStrTime
MsgBox Msg
End Sub

Wordperfect Quattro Pro note Reference: Using macros

 
Make sure that ShowTime is declared public so that you can access this macro from Quattro Pro.
 
For the purpose of this procedure, a Message Box was selected to display the date and time; however, you can create a new form and then display the time and date in this form. For more information about VBA, see Microsoft Visual Basic Help in the Visual Basic Editor.

Absolute and relative cell addresses

Wordperfect Quattro Pro btnbacktotopproc Reference: Using macros

The following is an example of absolute and relative addressing:

 
Absolute: []A:A1..D10
 
Relative: []P(0):C(0)R(0)..C(4)R(10)

When you record with relative references, the macro records cells in relation to each other, rather than recording exact cell addresses. For example, the macro indicates two cells to the right of the selector, rather than a specific cell. The following example shows how to use absolute and relative cell referencing in macros:

 
Absolute: []$A:$A$1..$D$10
 
Relative: [][]A:A1..D10

Using relative references increases macro portability (letting you use a macro with different notebooks), but hinders readability, since it is harder to track which cells the macro affects. If macros use the spreadsheet function @CELLPOINTER frequently, you can try relative references.

Relative referenc
es specify cells as offset from the cell selector. For example, the cell selector’s relative reference is []P(0):C(0)R(0).

Reference
Result
([ ])
Specifies that you are referring to the active notebook
P(0):
Indicates the number of spreadsheets from the selector (in this case, zero); it is optional (except when selecting an entire row or column)
C(0)
Indicates the number of columns from the selector
R(0)
Indicates the number of rows from the selector

The cell below the selector is []C(0)R(1), the cell to the right of it is []C(1)R(0), and the cell beneath the selector (on the next spreadsheet) is []P(1):C(0)R(0).

For more information about setting absolute and relative cell references, see “Setting cell addresses.”

If [] does not precede a relative reference, the relative reference is offset from the cell containing the macro command, not the cell selector. For example, if {BLANK C(1)R(0)} were stored in A:A16, playing the macro would erase the cell to the right of it (A:B16).

You can precede a relative reference with a colon (:) to affect the same cell, but on the active sheet. For example, if {BLANK :C(1)R(0)} were stored in A:A16, playing it when sheet B is active would erase the cell B:B16.

You can omit C( ) or R( ) to select entire rows or columns. For example, {SELECTBLOCK []P(0):C(0)} selects the column containing the active cell; {SELECTBLOCK []P(0):R(0)} selects the row containing the active cell. To select the three columns to the right of the active cell, use {SELECTBLOCK []P(0):C(1), C(3)}.

Relative references can use negative or positive offsets. For example, if the selector is in cell A2, you could use []C(0)R(-1), C(2)R(1) to specify the cells A1, C3.

Reference: Using macros