home *** CD-ROM | disk | FTP | other *** search
/ Chip: 25 Years Anniversary / CHIP_25Jahre_Jubilaeum.iso / downloads / 401065 / WPO11 / Data1.cab / _378B198ADAA44D6CABAF41B6D1FB45BE < prev    next >
Text File  |  2003-03-07  |  73KB  |  1,848 lines

  1. Using macros
  2.  
  3. A macro is a script containing instructions that you record and then play back to perform simple or complex tasks. For example, you can record a macro that prints a report. Or you can record a macro that opens a notebook, moves the insertion point to a specified place, and prompts a user to type information. 
  4.  
  5. In this section, you'll learn about
  6.  
  7.   recording and editing Quattro Pro macros
  8.   
  9.   working with macro libraries
  10.   
  11.   recording  and editing PerfectScript macros
  12.   
  13.   creating VBA macros
  14.   
  15.   debugging and editing a VBA macro
  16.   
  17.   using the PerfectScript class to change a Quattro Pro document
  18.   
  19.   working in Developer mode
  20.   
  21.   recording macros using relative and absolute cell references
  22.   
  23.   attaching macros to notebooks and buttons
  24.   
  25.   playing macros
  26.   
  27.   debugging Quattro Pro macros
  28.   
  29.   debugging PerfectScript macros
  30.   
  31.   customizing application settings using macros
  32.   
  33. For more information about using macros, see "Reference: Using macros."
  34.  
  35. Recording and editing Quattro Pro macros
  36.  
  37. With Quattro Pro, you can record actions as you perform them. Recording converts actions into macro commands and stores them as labels in a block. Quattro Pro does not record actions keystroke by keystroke. Instead, it translates keystrokes and mouse actions that invoke menu choices into one or more macro commands called command equivalents. This recording method is called logical recording. Macros recorded in this way are more efficient and can run with a customized Quattro Pro menu system. For example, a macro containing commands to print the active notebook runs even when the menu command is not in the active menu bar.
  38.  
  39. You can also type Quattro Pro macros if you prefer to enter the macro manually. You can type multiple macro commands in the same cell or type each separately in multiple cells. Macro commands are labels, therefore, Quattro Pro does not recognize a syntax error as you type it in; the error occurs only when you try to run the macro. Even a typing error can prevent a macro from running. To save debugging time, pay careful attention to the format of macro commands as you enter them, and record macros whenever possible. For information about macro syntax, see "Understanding Quattro Pro macro syntax."
  40.  
  41. You can also add a command to a macro script.
  42.  
  43. Quattro Pro lets you name the macros you record. Cell names make macros more readable and easier to remember. Give names to macros that reflect the tasks they perform. For example, PERCENT could be the name of a macro that changes the numeric format of the current cell to a percentage.
  44.  
  45. When naming macros, avoid names that are the same as macro command names; otherwise the macro commands are invalid. For example, suppose you name a macro READLN; this is also the name of a predefined macro command for reading a line from a file. If you try to use this command to read a line into cell A6 rather than {READLN A6}, Quattro Pro assumes you are playing the READLN macro rather than the {READLN} command.
  46.  
  47. To record a Quattro Pro macro
  48.  
  49. 1    Click Tools  Macro  Record.
  50.  
  51. 2    Enable the Quattro Pro macro option.
  52.  
  53. If you want to save the macro in an existing macro library, on the status bar, click the notebook name that contains the macro library.
  54.  
  55. 3    Select the cells in which to store the macro.
  56.  
  57. 4    Click OK.
  58.  
  59. 5    Perform the actions in the macro.
  60.  
  61. 6    Click Tools  Macro  Record.
  62.  
  63. Notes
  64.  
  65.   You can store a macro on the spreadsheet where you perform the macro or on a spreadsheet specifically assigned to the macro.
  66.   
  67.   At the end of the macro, leave a line blank so the macro terminates without user intervention. Otherwise, the macro interprets labels below it as macro commands.
  68.   
  69.   The recording of a macro is noted by  on the Application Bar.
  70.   
  71.   For more information about saving a macro in an existing macro library see "Working with macro libraries."
  72.   
  73.   When you select cells to store the macro in, select a single cell if there is no chance of overwriting data in the cells below (Quattro Pro fills the cells below as necessary). When you select more than one cell, the macro is confined only to those cells, and stops recording when they are full.
  74.   
  75. To pause or resume recording a Quattro Pro macro
  76.  
  77.   Click Tools  Macro  Pause.
  78.   
  79. To type a Quattro Pro macro
  80.  
  81. 1    Click in the first cell where you want to store the macro.
  82.  
  83. 2    Type the macro commands you want.
  84.  
  85. 3    Type {QUIT}.
  86.  
  87. Note
  88.  
  89.   When you type commands in more than one cell, be sure the entries proceed downward (A1, A2, A3) with no empty cells between them. Each cell must contain a label or a text formula.
  90.   
  91. Tip
  92.  
  93.   You can also indicate the end of a macro by typing {RETURN} or leaving an empty cell below the last cell of the macro.
  94.   
  95. To add a command to a macro script
  96.  
  97. 1    Click a spreadsheet containing the macro script.
  98.  
  99. 2    Click the cell above where you want to add the command.
  100.  
  101. 3    Click Insert  Insert row.
  102.  
  103. 4    Click OK.
  104.  
  105. 5    Type the new command.
  106.  
  107. To delete a command from a macro script
  108.  
  109. 1    Click a spreadsheet containing the macro script.
  110.  
  111. 2    Click the row label containing the command you want to delete.
  112.  
  113. 3    Click Edit  Delete cells.
  114.  
  115. To name a Quattro Pro macro
  116.  
  117. 1    Click a spreadsheet containing the macro script.
  118.  
  119. 2    Select the cells containing the macro you want to name.
  120.  
  121. 3    Click Insert  Name  Name cells.
  122.  
  123. 4    Type the name in the Name box.
  124.  
  125. Working with macro libraries
  126.  
  127. The best way to store macros is in a macro library, a special notebook reserved for macros that you can access from any notebook. You can create a library Macro libraries can
  128.  
  129.   simplify linked access
  130.   
  131.   make tracking macros easier
  132.   
  133.   ensure that macros do not interfere with the notebook data and conversely
  134.   
  135.   save disk space by using one set of macros for a group of notebooks
  136.   
  137.   store a set of macros that can be copied into individual notebooks as you need them
  138.   
  139.   create a separate set of macros for each application or type of notebook you work with
  140.   
  141. You should keep only one macro library open at a time. When two open libraries contain a macro with the same name, it is difficult to predict which macro will play. Quattro Pro searches only open macro libraries for macros; closed libraries are ignored.
  142.  
  143. You can also create a system notebook. You can use system notebooks to hold application macros and ensure their availability while Quattro Pro is running. You can hide system notebooks. A system notebook, when hidden, stays open even when users close all notebooks.
  144.  
  145. To create a macro library
  146.  
  147. 1    Click Format  Notebook properties.
  148.  
  149. 2    Click the Macro library tab.
  150.  
  151. 3    Enable the Yes option.
  152.  
  153. 4    Click OK.
  154.  
  155. 5    Click File  Save.
  156.  
  157. To create a system notebook
  158.  
  159. 1    Click Format  Notebook properties.
  160.  
  161. 2    Click the System tab.
  162.  
  163. 3    Enable the Yes option.
  164.  
  165. If you also want to designate the notebook as a macro library, click the Macro library tab, and enable the Yes option.
  166.  
  167. 4    Click OK to close the dialog box.
  168.  
  169. To hide a system notebook
  170.  
  171. 1    Click Format  Notebook properties.
  172.  
  173. 2    Click the Password level tab. 
  174.  
  175. 3    Enable the Medium option
  176.  
  177. 4    Click OK.
  178.  
  179. 5    In the Enter password dialog box, type a password.
  180.  
  181. Tip
  182.  
  183.   You can also hide a system notebook by clicking Window  Hide.
  184.   
  185. Recording and editing PerfectScript macros
  186.  
  187. You can use PerfectScript macros not only with Quattro Pro, but also with other Corel applications such as Corel Presentations and WordPerfect.
  188.  
  189. PerfectScript is a command-based language that records the results of keystrokes or mouse selections rather than the keystrokes themselves. PerfectScript includes commands that direct the function of the macros. These commands let you create macros that can prompt for user input, make decisions based on conditions in a notebook, access system variables, and so on.
  190.  
  191. You can record PerfectScript macros. A recorded macro includes only product commands.
  192.  
  193. You can also type a macro in WordPerfect and play it in Quattro Pro. A typed macro can include non-recordable statements that specify how a macro performs a task. When writing this kind of macro, you specify the conditions for playing assignments, loops, and programming commands.
  194.  
  195. Once you have created a PerfectScript macro script you can create a .wcl file. The .wcl file is necessary for debugging PerfectScript macros.
  196.  
  197. In Quattro Pro you can edit a PerfectScript macro in two ways: in WordPerfect or in the PerfectScript Macro Facility.
  198.  
  199. To record a PerfectScript macro
  200.  
  201. 1    Click Tools  Macro  Record.
  202.  
  203. 2    Enable the PerfectScript macro option.
  204.  
  205. 3    Type a filename in the Filename box.
  206.  
  207. 4    Click OK.
  208.  
  209. 5    Perform the actions in a task.
  210.  
  211. Each action is recorded and written as one or more macro commands in the macro file.
  212.  
  213. 6    Click Tools  Macro  Record.
  214.  
  215. Notes
  216.  
  217.   The recording of a macro is noted by  on the application bar.
  218.   
  219.   You cannot record a PerfectScript macro that pauses for user input. If you want the macro to pause, edit it after recording it.
  220.   
  221. To pause or resume recording a PerfectScript macro
  222.  
  223.   Click Tools  Macro  Pause.
  224.   
  225. To type a PerfectScript macro
  226.  
  227. 1    Start WordPerfect.
  228.  
  229. 2    Click Tools  Macro  Macro toolbar.
  230.  
  231. 3    Click the Commands button on the Macro toolbar.
  232.  
  233. 4    Choose a command type from the Command type list box.
  234.  
  235. If the command requires a parameter, choose a parameter from the Parameters list box.
  236.  
  237. If the command requires an enumeration, choose an enumeration from the Enumerations list box.
  238.  
  239. 5    Type any additional parameters or values in the Command edit box.
  240.  
  241. 6    Click Insert.
  242.  
  243. 7    Click Save & compile on the macro toolbar.
  244.  
  245. Note
  246.  
  247.   Enumerations are used to set parameter values when parameter values are limited to a specific set of values. For example, the FileClose command lets you close a file. It has a parameter named DoSave? with two enumerations, Yes! and No!.
  248.   
  249. Tip
  250.  
  251.   You can also type a PerfectScript macro by click Start  Programs  WordPerfect 11  Utilities  PerfectScript 11 and clicking Help  Macro command browser.
  252.   
  253. To create a .wcl file
  254.  
  255. 1    Click Tools  Macro  Edit.
  256.  
  257. 2    Choose the drive and folder where the macro is stored.
  258.  
  259. 3    Double-click the filename.
  260.  
  261. WordPerfect opens.
  262.  
  263. 4    Click Options  Compile with debug on the macro tools toolbar.
  264.  
  265. 5    Click Save & compile on the macro toolbar.
  266.  
  267. 6    In the PerfectScript compiler listing box, click OK.
  268.  
  269. Note
  270.  
  271.   The .wcl file defaults to the same location and name as the .wcm file.
  272.   
  273. Tip
  274.  
  275.   You can open the macro tools toolbar in WordPerfect by clicking View  Toolbars, and enabling the Macro tools check box in the Toolbar list.
  276.   
  277. To edit a PerfectScript in the PerfectScript Macro Facility
  278.  
  279. 1    Click Tools  Macro  Edit.
  280.  
  281. 2    Choose the drive and folder where the macro is stored.
  282.  
  283. 3    Double-click the filename.
  284.  
  285. To edit a PerfectScript macro in WordPerfect
  286.  
  287. 1    On the Windows taskbar, click Start  Programs  WordPerfect 11  Utilities  PerfectScript 11.
  288.  
  289. 2    Click File  Edit.
  290.  
  291. 3    Choose a drive and folder where the file is stored.
  292.  
  293. 4    Double-click a filename.
  294.  
  295. This starts WordPerfect and displays the macro commands.
  296.  
  297. 5    Edit the macro.
  298.  
  299. Creating VBA macros
  300.  
  301. Quattro Pro lets you start Visual Basic for Applications (VBA) from Quattro Pro. You can display the VBA toolbar, which provides quick access to commands such as playing a macro or starting the VBA Editor.
  302.  
  303. With VBA, you can create a project macro. You can play a project macro only in the document which was used to create it.
  304.  
  305. You can create a project VBA macro by creating a public method for the ThisDocument object. The term public refers to the access level. If a method is public, it can be accessed from outside the class. This means that you can call it from the host application. If a method is private, then only methods in the same class can access it. Every public method that belongs to the ThisDocument class is a project macro.
  306.  
  307. You can copy PerfectScript to a VBA code module. You can also copy Quattro Pro macro script to a VBA code module.
  308.  
  309. You should always play a macro once you have created it. For more information about playing a PerfectScript macro see "To play a PerfectScript macro."
  310.  
  311. For more information about VBA, see the Microsoft Visual Basic Help in the Visual Basic Editor.
  312.  
  313. To start VBA from Quattro Pro
  314.  
  315.   Click Tools  Visual Basic  Visual Basic Editor.
  316.   
  317. Note
  318.  
  319.   For more information about VBA, see the Microsoft Visual Basic Help in the Visual Basic Editor.
  320.   
  321. To display the VBA toolbar
  322.  
  323. 1    Click View  Toolbars.
  324.  
  325. 2    Enable the Visual Basic check box in the Toolbar list.
  326.  
  327. Note
  328.  
  329.   For more information about VBA, see the Microsoft Visual Basic Help in the Visual Basic Editor.
  330.   
  331. To create a VBA project macro in Quattro Pro
  332.  
  333. 1    Click Tools  Visual Basic  Visual Basic Editor.
  334.  
  335. 2    In the Project explorer Docker window, double-click the VBAProject (NoteBk1) in the list of categories.
  336.  
  337. 3    Click Insert  UserForm.
  338.  
  339. 4    In the Toolbox dialog box, drag any control to the user form.
  340.  
  341. 5    Modify any of the control's attributes, in the Properties Docker window.
  342.  
  343. 6    Double-click a control.
  344.  
  345. 7    In the Notebk1 code module window, type the code that responds to the activation of the control.
  346.  
  347. 8    Open the QuattroPro objects folder in the Project explorer Docker window.
  348.  
  349. 9    Double-click ThisNotebook.
  350.  
  351. 10In the Notebk1 code module window, type the code that adds a new method to the notebook.
  352.  
  353. To copy PerfectScript to a VBA code module
  354.  
  355. 1    Open the .wcm file containing the PerfectScript macro.
  356.  
  357. 2    Select the macro.
  358.  
  359. 3    Click Edit  Copy.
  360.  
  361. 4    Click Tools  Visual Basic  Visual Basic Editor.
  362.  
  363. 5    In the Project explorer Docker window, double-click VBAProject (NoteBk1)  Quattro Pro objects  ThisNotebook in the list of categories.
  364.  
  365. 6    In the Notebok1 code module window, type Public Sub and the name of the sub.
  366.  
  367. 7    Within the Public Sub, type Application.PerfectScript.
  368.  
  369. 8    Click Edit  Paste.
  370.  
  371. 9    Replace the first brace from the line of code with a period.
  372.  
  373. 10Choose the VBA code that is equivalent to the PerfectScript code from the list.
  374.  
  375. 11Type End with at the end of all the code and within the Public Sub.
  376.  
  377. To copy Quattro Pro macros to a VBA code module
  378.  
  379. 1    Open the file containing the Quattro Pro macro.
  380.  
  381. 2    Select the macro.
  382.  
  383. 3    Click Edit  Copy.
  384.  
  385. 4    Click Tools  Visual Basic  Visual Basic Editor.
  386.  
  387. 5    In the Project explorer Docker window, double-click VBAProject (NoteBk1)  Quattro Pro objects  ThisNotebook in the list of categories.
  388.  
  389. 6    In the Notebok1 code module window, type Public Sub and the name of the sub.
  390.  
  391. 7    Within the Public Sub, type Application.PerfectScript.
  392.  
  393. 8    Click Edit  Paste.
  394.  
  395. 9    Replace the first brace from the line of code with a period.
  396.  
  397. 10Choose the VBA code that is equivalent to the Quattro Pro code from the list.
  398.  
  399. 11Type End with at the end of your code and within the Public Sub.
  400.  
  401. To play a VBA macro
  402.  
  403. 1    Click Tools  Visual Basic  Play.
  404.  
  405. 2    Choose VBAProject(NoteBk) from the Macros in list box.
  406.  
  407. 3    Choose a macro from the Macro name list box.
  408.  
  409. 4    Click Run.
  410.  
  411. Tip
  412.  
  413.   You can also play a VBA macro by clicking the Play button on the Visual Basic toolbar.
  414.   
  415. Debugging and editing a VBA macro
  416.  
  417. You can debug VBA macros. Debugging lets you step through code line by line to ensure that a macro executes properly. For example, if you are at a point in the code where a variable is about to be assigned a value, you can step into this line of code to determine the value of the variable at runtime.
  418.  
  419. You can also edit a VBA macro. Editing a macro involves going directly to start of the code, whereas debugging lets you step through each line of the code.
  420.  
  421. To debug a VBA macro
  422.  
  423. 1    Click Tools  Visual Basic  Play.
  424.  
  425. 2    Choose a macro from the Macro name list box.
  426.  
  427. 3    Click Step into.
  428.  
  429. 4    In Microsoft Visual Basic, click Debug  Step into.
  430.  
  431. 5    Modify the code.
  432.  
  433. Note
  434.  
  435.   After you click Step into, you can position the pointer over a specific variable to determine the value of the variable. For more information about debugging in VBA, see the Microsoft Visual Basic Help in the Visual Basic Editor.
  436.   
  437. To edit a VBA macro
  438.  
  439. 1    Click Tools  Visual Basic  Play.
  440.  
  441. 2    Choose a macro from the Macro name list box.
  442.  
  443. 3    Click Edit.
  444.  
  445. 4    Edit the code as necessary.
  446.  
  447. Note
  448.  
  449.   For more information about editing VBA, see the Microsoft Visual Basic Help in the Visual Basic Editor.
  450.   
  451. Using the PerfectScript class to change a Quattro Pro document
  452.  
  453. 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. You can change a Quattro Pro document using the PerfectScript class.
  454.  
  455. To change a Quattro Pro document using the PerfectScript class
  456.  
  457. 1    Click Tools  Visual Basic  Visual Basic Editor.
  458.  
  459. 2    In the Project explorer Docker window, double-click VBAProject (NoteBk1)  Quattro Pro objects  ThisNotebook in the list of categories.
  460.  
  461. 3    In the Notebok1 code module window, type Public Sub and the name of the sub.
  462.  
  463. 4    Below End Sub, type Private Sub and the name of the sub.
  464.  
  465. 5    Press ENTER.
  466.  
  467. You will notice that VBA automatically adds End Sub to you code
  468.  
  469. 6    Within the Private Sub, type PerfectScript. and choose the necessary commands.
  470.  
  471. 7    Within the Public Sub, type the name of the Private Sub.
  472.  
  473. Notes
  474.  
  475.   If you declare the first method as private, you will not be able to run it from Quattro Pro.
  476.   
  477.   For more information about VBA, see the Microsoft Visual Basic Help in the Visual Basic Editor.
  478.   
  479. Working in Developer mode
  480.  
  481. You can start Quattro Pro to work in Developer mode. Developer mode adds special properties to property menus and lets you use the shortcut key Ctrl + M, which varies in function depending on the current program state. In most instances, Ctrl + M restores the standard Quattro Pro application bar and input line. In Developer mode, you can modify property settings or change the title displayed in the Quattro Pro title bar. Additional properties of drawn objects in a chart or map window let you read or change property settings with macro commands, link commands, and spreadsheet functions (Name property). You do not have to be in Developer mode to change or read these property settings; macro commands can always access them.
  482.  
  483. You can also control whether users can access object property settings.
  484.  
  485. To start Quattro Pro in Developer mode
  486.  
  487. 1    On the Windows taskbar, click Start  Run.
  488.  
  489. 2    Type the Quattro Pro command with its path, followed by a space and /d.
  490.  
  491. For example, qpw.exe /d.
  492.  
  493. To modify the title bar in Developer mode
  494.  
  495. 1    Click Tools  Settings.
  496.  
  497. 2    In the list of categories, double-click Workspace, Application, and click the Developer options.
  498.  
  499. 3    Type a new title in the Application title box.
  500.  
  501. To modify the properties of a chart or map object in Developer mode
  502.  
  503.   Click the Property button on the toolbar.
  504.   
  505. To disable access to property settings in Developer mode
  506.  
  507. 1    Click Tools  Settings.
  508.  
  509. 2    In the list of categories, double-click Workspace, Application, and click the Developer options.
  510.  
  511. 3    Enable the No option.
  512.  
  513. Tip
  514.  
  515.   To enable property settings after disabling them, press Ctrl + M in all states other than debug mode.
  516.   
  517. Recording macros using relative and absolute cell references
  518.  
  519. By default, addresses in macro commands use absolute cell addressing like A1 and C6. You can record absolute cell references. However, you can also record macro commands that use relative references so you can play the macro in different parts of a notebook or in different notebooks. For more information on absolute and relative cell addresses, see "Absolute and relative cell addresses."
  520.  
  521. To record a macro using relative or absolute cell references
  522.  
  523. 1    Click Tools  Macro  Options.
  524.  
  525. 2    Enable one of the following options:
  526.  
  527.   Relative
  528.   
  529.   Absolute
  530.   
  531. Attaching macros to notebooks and buttons
  532.  
  533. Quattro Pro lets you attach macros to notebooks. A macro attached to a notebook can play when you open or close the notebook.
  534.  
  535. You can also attach a macro to a button. The button plays the macro. You can link a button you create to a macro script.
  536.  
  537. You can attach a macro to a keystroke. Macros attached to keystrokes are activated when you press the keystroke.
  538.  
  539. You can use the macro buttons you create to display the dialog boxes you create in Quattro Pro. For information about creating dialog boxes, see "Working with custom dialog boxes and controls."
  540.  
  541. Once you create a macro button, you can change the button properties by modifying the box type, border color, protection, and button name.
  542.  
  543. You can also attach a Quattro Pro or PerfectScript macro to a customized a command. For example, you can create a toolbar button and display it on any of the toolbars. When you click the button, the macro executes.
  544.  
  545. To attach a macro to a notebook
  546.  
  547. 1    Right-click the top-left cell of the macro.
  548.  
  549. 2    Click Name cells.
  550.  
  551. 3    Type one of the following in the Name box:
  552.  
  553.   _nbstartmacro-creates a startup macro that plays when you open the notebook
  554.   
  555.   _nbexitmacro-runs a macro when you close the notebook
  556.   
  557.   any block name (for example, "Fred" could be the name of a macro stored in a block)
  558.   
  559. 4    Click Add.
  560.  
  561. 5    Click Close.
  562.  
  563. Tip
  564.  
  565.   You can also create a startup macro that plays when you open the notebook by typing \0 (backslash zero).
  566.   
  567. To create a macro button
  568.  
  569. 1    Click Insert  Form control  Push button.
  570.  
  571. 2    Click the spreadsheet.
  572.  
  573. 3    Drag the button to position it on the spreadsheet.
  574.  
  575.  
  576.  
  577. You can also    
  578.  
  579. Display a label on a macro button    Right-click the button, and click Selection properties. Click the Label text tab. In the Enter text box, type the text you want to display on the button.
  580.  
  581. Attach a macro button to a URL address    Right-click the button, and click Selection properties. Click the Macro tab. Click Link to URL. In the Button URL dialog box, type the URL address in the URL box.
  582.  
  583.  
  584.  
  585. Tips
  586.  
  587.   Clicking the spreadsheet creates a button at the default size. If you want to create a custom size button, drag to create the button.
  588.   
  589.   You can also create a macro button by opening the Form Controls flyout on the Drawing tools toolbar and clicking the Push button tool.
  590.   
  591. To link a button to a macro
  592.  
  593. 1    Right-click a button, and click Selection properties.
  594.  
  595. 2    Click the Macro tab.
  596.  
  597. 3    In the Enter macro box, type { (an opening brace), the macro command name, and } (a closing brace).
  598.  
  599. Note
  600.  
  601.   The maximum length for a macro command name is 200 characters.
  602.   
  603. To attach a macro to a keystroke
  604.  
  605. 1    Select the starting cell of the macro.
  606.  
  607. 2    Click Insert  Name  Name cells.
  608.  
  609. 3    In the Name box, type ' (an apostrophe) and \ (a backslash), followed by a letter of the alphabet.
  610.  
  611. 4    Click Add.
  612.  
  613. Note
  614.  
  615.   Macros assigned to keystrokes play by holding down Ctrl + Shift and the letter assigned to the name. Avoid using the same alphabet letters already assigned to shortcuts in the application. For more information on keyboard shortcuts, see "Quattro Pro keyboard shortcuts."
  616.   
  617. To link a macro button to a dialog box
  618.  
  619. 1    Right-click the macro button, and click Selection properties.
  620.  
  621. 2    Click the Macro tab.
  622.  
  623. 3    Click Execute dialog.
  624.  
  625. 4    In the Execute dialog dialog box, choose a dialog box from the Active dialog list.
  626.  
  627. 5    Type a cell reference in the Result cell box.
  628.  
  629. After the dialog box is closed, this cell contains 1 or 0. The value 1 means the dialog box was closed by clicking OK; the value 0 means it was closed by clicking Cancel.
  630.  
  631. 6    Type a cell reference in the Values range box:
  632.  
  633. Specify the cells that contain initial settings for the dialog box. When the dialog box is closed, its final settings are written into these cells.
  634.  
  635. Tip
  636.  
  637.   You can also select a cell reference by clicking the Range picker tool.
  638.   
  639. To modify a macro button
  640.  
  641. 1    Right-click a macro button, and click Selection properties.
  642.  
  643. 2    Click one of the following tabs:
  644.  
  645.   Border color-changes the color around the outside of the button
  646.   
  647.   Box type-changes the thickness of the line around the button or applies a shadow effect
  648.   
  649.   Protection-locks the button, preventing users from moving or changing the button when protections are set at the spreadsheet level
  650.   
  651.   Object name-changes the button's name (used when referring to the button in a macro)
  652.   
  653.   Print- enables the printing of chart objects on the spreadsheet.
  654.   
  655.   Label text-changes the name displayed on the label
  656.   
  657.   Macro-changes the button activation, URL link, or dialog box that displays when clicking the button
  658.   
  659. 3    Modify any settings.
  660.  
  661. To attach a macro to a toolbar button
  662.  
  663. 1    Click Tools  Customize.
  664.  
  665. 2    In the list of categories, double-click Workspace, Customize, and click Commands.
  666.  
  667. 3    Choose Macros from the list box.
  668.  
  669. 4    Choose a button graphic from the list.
  670.  
  671. 5    Click the Macro command category tab.
  672.  
  673. 6    Enable one of the following options:
  674.  
  675.   Quattro Pro macro
  676.   
  677.   PerfectScript macro
  678.   
  679. 7    Type the macro in the Enter macro box.
  680.  
  681. 8    Click the Appearance tab, and type a name in the Caption box.
  682.  
  683. 9    Click the General tab, and type text to use as the button's Tool Tip in the Tooltip help box.
  684.  
  685. To add a macro button to the toolbar area
  686.  
  687. 1    Click Tools  Customize.
  688.  
  689. 2    In the list of categories, double-click Workspace, Customize, and click Commands.
  690.  
  691. 3    Choose Macros from the list box.
  692.  
  693. 4    Select a macro button you want to add to the toolbar area.
  694.  
  695. 5    Drag the macro button to the appropriate toolbar.
  696.  
  697. Playing macros
  698.  
  699. You can play a Quattro Pro macro from the menu or by using the macro buttons on a customized toolbar. For information about creating customized toolbars, see "Working with toolbars."
  700.  
  701. Playing a PerfectScript macro is similar to playing a Quattro Pro macro. However, PerfectScript macros cannot be used for startup or exit macros.
  702.  
  703. You can have a play a macro each time you open or close a notebook. For example, Quattro Pro can enter the current date and time when you open a notebook. You can also play a macro each time you start Quattro Pro.
  704.  
  705. You may want to have Quattro Pro launch a macro whenever a user opens a particular notebook. When you open a file that contains a PerfectScript or Quattro Pro native startup macro, the macro launches as soon as you open the file. For your convenience, Quattro Pro displays a message alerting you that the file contains this kind of macro. Quattro Pro can have the same macro startup every time a user launches Quattro Pro. You can also design an exit macro to make sure any ongoing operations are completed so you can exit the notebook without problems.
  706.  
  707. To play a Quattro Pro macro
  708.  
  709. 1    Click Tools  Macro  Play.
  710.  
  711. 2    Enable the Quattro Pro macro option.
  712.  
  713. 3    Type the location of the macro in the Location box.
  714.  
  715. Tips
  716.  
  717.   You can also play a Quattro Pro macro by pressing ALT + F2.
  718.   
  719.   If the macro is in another notebook, use full linking syntax to specify the macro location (for example, [LIBRARY]A:C26).
  720.   
  721. To play a PerfectScript macro
  722.  
  723. 1    Click Tools  Macro  Play.
  724.  
  725. 2    Enable the PerfectScript macro option.
  726.  
  727. 3    Type a filename in the filename box.
  728.  
  729. Tip
  730.  
  731.   You can play a PerfectScript macro by pressing Alt + F2.
  732.   
  733. To play a startup or exit macro in a notebook
  734.  
  735. 1    Select the first cell of a macro.
  736.  
  737. 2    Click Insert  Name  Name cells.
  738.  
  739. 3     In the Name box, type one of the following:
  740.  
  741.   _NBSTARTMACRO-plays a startup macro when opening the notebook
  742.   
  743.   _NBEXITMACRO-plays an exit macro when closing the notebook
  744.   
  745. 4    Click Add.
  746.  
  747. 5    Click Close.
  748.  
  749. Note
  750.  
  751.   If a notebook is linked to other notebooks, a Links dialog box displays when you open the notebook. To ensure that _NBSTARTMACRO plays correctly in a notebook that contains links, begin the macro with {ESC}. This cancels the Links dialog box.
  752.   
  753. To assign an existing macro as the startup macro
  754.  
  755. 1    Click Tools  Settings.
  756.  
  757. 2    In the list of categories, double-click Workspace, Application, and click Macro.
  758.  
  759. 3    Type a new name in the Startup box.
  760.  
  761. Note
  762.  
  763.   If you modify the default startup macro name, existing macros named \0 will no longer play automatically. For example, if you set the startup name to AUTOSTART, macros named \0 do not play automatically; they must be renamed AUTOSTART.
  764.   
  765. To assign a macro to launch automatically when Quattro Pro launches
  766.  
  767. 1    Click Tools  Settings.
  768.  
  769. 2    In the list of categories, double-click Workspace, Application, and click File options.
  770.  
  771. 3    Type the name of the macro in the Autoload file box.
  772.  
  773. Tip
  774.  
  775.   You can also locate the macro by clicking the Browse button in the Autoload file box.
  776.   
  777. To stop a macro while it is playing
  778.  
  779.   Click Ctrl+BREAK.
  780.   
  781. Note
  782.  
  783.   If Ctrl + BREAK has been disabled with {BREAKOFF}, you cannot stop the macro. If you need to use {BREAKOFF} in the macro, add it as a last step after debugging the macro.
  784.   
  785. Debugging Quattro Pro macros
  786.  
  787. Once you create a Quattro Pro macro, you can turn on the macro debugger to check for errors in the code. This allows you to
  788.  
  789.   assign standard or conditional breakpoints
  790.   
  791.   assign trace cells
  792.   
  793.   assign cells for editing
  794.   
  795. You control when debug mode is active and turn it on or off as needed. You can play a macro while in debug mode. You can also edit Quattro Pro macro cells from the debugger.
  796.  
  797. If you know that most of a macro is correct, you can use breakpoints to play parts of a macro at full speed and step through other parts that may have problems. There are two types of breakpoint:
  798.  
  799.   Standard breakpoints-pause the macro at the breakpoint cell
  800.   
  801.   Conditional breakpoints-pause the macro when the result of a logical formula in the conditional breakpoint cell is true
  802.   
  803. You can set up to four conditional breakpoints for each notebook. Conditional breakpoints can be extremely valuable. Suppose you have a macro loop that contains date calculations and you want it to pause whenever December is reached. If the date is in cell A5, assign the first conditional breakpoint to a cell containing the following formula:
  804.  
  805. MONTH(A5)=12
  806.  
  807. As long as the formula in the condition cell is true (has a value of 1), the macro plays in step-by-step mode. Once the formula is false (has a value of 0), the macro stops playing.
  808.  
  809. You can set up to four standard breakpoints. Sometimes a problem appears after many repetitions of the same commands in a macro loop. If this is the case, you can set a pass count to indicate how many times to pass through the breakpoint before stopping. The default, 1, stops the macro every time it passes through the breakpoint. Setting it to 2 stops the macro every other pass.
  810.  
  811. Conditional breakpoints debug a macro using Boolean logic. The debugging process pauses only when a positive result (1) is returned by playing the script.
  812.  
  813. Macros often affect the contents of one or more cells. By tracing these cells, you can see what the macro is doing. You can specify up to four trace cells whose addresses and current values display during debugging in the debugger window. The debugger updates as the contents of the trace cells change.
  814.  
  815. To play a Quattro Pro macro in debug mode
  816.  
  817. 1    Click Tools  Macro  Debugger. 
  818.  
  819. 2    Click Tools  Macro  Play.
  820.  
  821. 3    Enable the Quattro Pro macro option.
  822.  
  823. 4    Type the location of a macro in the Location box.
  824.  
  825. 5    Click in the debugger window to step through each macro command until you find an error.
  826.  
  827.  
  828.  
  829. You can also    
  830.  
  831. Exit macro debug mode    Click Tools  Macro  Debugger.
  832.  
  833. Stop macro before debugging is finished    Click Terminate.
  834.  
  835.  
  836.  
  837. Tip
  838.  
  839.   You can also play a macro in debug mode by pressing Shift + F2.
  840.   
  841. To set a standard breakpoint in a Quattro Pro macro
  842.  
  843. 1    Click Tools  Macro  Debugger. 
  844.  
  845. 2    Click Tools  Macro  Play.
  846.  
  847. 3    Enable the Quattro Pro macro option.
  848.  
  849. 4    Type the location of a macro in the Location box.
  850.  
  851. 5    Click OK.
  852.  
  853. 6    Click Breakpoints, and click a breakpoint to set.
  854.  
  855. 7    In the Breakpoint dialog box, type the breakpoint cell reference in the Location box.
  856.  
  857. 8    Type a value in the Pass count box.
  858.  
  859. 9    Click OK, and press the SPACEBAR.
  860.  
  861.  
  862.  
  863. You can also    
  864.  
  865. Remove standard breakpoints    Type 0 in the Pass count box.
  866.  
  867. Clear all trace cells and breakpoints    Click Reset.
  868.  
  869.  
  870.  
  871. Tip
  872.  
  873.   You can also resume stepping through the macro by clicking Go.
  874.   
  875. To set a conditional breakpoint in a Quattro Pro macro
  876.  
  877. 1    Click Tools  Macro  Debugger. 
  878.  
  879. 2    Click Tools  Macro  Play.
  880.  
  881. 3    Enable the Quattro Pro macro option.
  882.  
  883. 4    Type the location of a macro in the Location box.
  884.  
  885. 5    Click OK.
  886.  
  887. 6    Click Conditional, and click a conditional breakpoint.
  888.  
  889. 7    In the Conditional cell dialog box, type the cell reference in the Location box.
  890.  
  891. 8    Click OK.
  892.  
  893. 9    Press the SPACEBAR.
  894.  
  895. Tip
  896.  
  897.   You can also resume stepping through the macro by clicking Go.
  898.   
  899. To set a trace cell for a Quattro Pro macro
  900.  
  901. 1    Click Tools  Macro  Debugger. 
  902.  
  903. 2    Click Tools  Macro  Play.
  904.  
  905. 3    Enable the Quattro Pro macro option.
  906.  
  907. 4    Type the location of a macro in the Location box.
  908.  
  909. 5    Click OK.
  910.  
  911. 6    Click Trace, and click a trace cell.
  912.  
  913. 7    In the Trace cell dialog box, type the trace cell reference in the Location box.
  914.  
  915. 8    Click OK.
  916.  
  917. To edit macro cells from the macro debugger
  918.  
  919. 1    Click Tools  Macro  Debugger.
  920.  
  921. 2    Click Tools  Macro  Play.
  922.  
  923. 3    Enable the Quattro Pro macro option.
  924.  
  925. 4    Type the location of a macro in the Location box.
  926.  
  927. 5    Click OK.
  928.  
  929. 6    Click Edit.
  930.  
  931. 7    In the Edit cell dialog box, type the edit cell reference in the Cells box.
  932.  
  933. 8    Edit the contents that display in the Content box.
  934.  
  935. Debugging PerfectScript macros
  936.  
  937. PerfectScript macros are written with an editor and saved as a source file. The macro compiler creates an object, which it saves in a hidden area of the source (the macro compiler does not create a separate object file). When you save a source file, the object is destroyed. It is recreated each time the source file is compiled. A compiled source file (macro) contains instructions that are executed when you play the macro.
  938.  
  939. A macro compiler is used to compile or "translate" macros so that WordPerfect Office applications can play them. Macros in PerfectScript are compiled when you record, play, or save them. The tool used for compiling PerfectScript macros is the PerfectScript Debugger.
  940.  
  941. Compilation errors
  942.  
  943. Sometimes, when you type or edit a macro, errors are created. For example, if you mistype a word, when you compile the macro, a compile-time syntax error displays a syntax error message. The compiler does not recognize typographical errors and guesses that it is a label's calling statement. When the compiler reaches the end of the file and does not find a corresponding label, it displays a syntax error message. The message contains information about the error and its location. The compiler makes a best guess and may not always be accurate. The compiler identifies syntax errors and suggests solutions.
  944.  
  945. Common syntax errors are caused by
  946.  
  947.   missing semicolons between parameters
  948.   
  949.   missing parentheses
  950.   
  951.   missing double quotation marks
  952.   
  953.   missing command in a conditional or loop statement
  954.   
  955.   undefined calling statements
  956.   
  957.   using commas between parameters instead of semicolons
  958.   
  959. Run-time errors
  960.  
  961. Run-time is the same as execution time. Run-time errors occur while the macro is playing. Referencing a variable that has not been assigned a value causes a run-time error. Run-time error messages identify errors that occur while the macro plays and show where the errors occur.
  962.  
  963. For users familiar with other programming languages such as Visual Basic or C++, the PerfectScript Debugger has many of the same features and buttons found in those language compilers.
  964.  
  965. Debugging breakpoints
  966.  
  967. Use breakpoints to indicate locations in the macro where execution of the macro should be interrupted and suspended, and where the debugger should become active. While the macro executes statements, the debugger is mostly inactive, and the debugger state message line displays the text "Macro is running." However, the debugger is not completely disabled. You can interrupt the macro. This causes the debugger to become active, as if there were a breakpoint at the point where the macro is currently executing. Breakpoint commands are also available while the macro is running, so that you can add and remove breakpoints.
  968.  
  969. You can stop a macro at any line, DLL call, or other place in the macro. A dialog box displays the labels, functions, procedures, and variables being passed, so that you can check them. All breakpoints allow a message to be logged to the debugger event log.
  970.  
  971. The PerfectScript Debugger automatically creates three breakpoints: Macro Start, Macro End, and Error. It marks the breakpoints it adds with an exclamation mark (!), which can be removed if desired.
  972.  
  973. Debug options
  974.  
  975. When the debugger stops at a macro statement, it stops before the indicated statement executes. The PerfectScript Debugger provides the following options to continue macro execution:
  976.  
  977. To play a PerfectScript macro in debug mode
  978.  
  979. 1    Click Tools  Macro  Debugger.
  980.  
  981. 2    Click Tools  Macro  Play.
  982.  
  983. 3    Enable the PerfectScript macro option.
  984.  
  985. 4    Type a filename in the Filename box.
  986.  
  987. 5    Click OK.
  988.  
  989. 6    In the PerfectScript debug dialog box, click Debug and choose one of the following menu commands:
  990.  
  991.   Continue-continues executing the macro until the next breakpoint
  992.   
  993.   Step into-executes the next statement
  994.   
  995.   Step over-executes the label or routine call without stopping until debugging is complete. This will stop the macro at the next statement in the current label or routine.
  996.   
  997.   Step out-executes the macro until the next return is encountered, if you have entered a routine or label
  998.   
  999.   Run to cursor-executes to the line below the cursor in the macro source list
  1000.   
  1001.   Skip to cursor-skips a series of statements without executing them; if some statements need to be repeated, sets the next statement to be executed by the Debugger, without executing any statements between the current point and the new line.
  1002.   
  1003.   Animate-repeats the next Continue or Step command until you stop it, or until the macro ends. Between each command, the Debugger displays for the amount of time you specify in the Settings dialog box.
  1004.   
  1005. Notes
  1006.  
  1007.   Use the Skip to cursor menu command with extreme caution, since skipping to a line that is not within the same label or routine could cause the internal macro execution to become invalid, which will almost certainly result in execution failure.
  1008.   
  1009.   You need a .wcl file in the same folder as the PerfectScript macro file. For information on creating a .wcl file see "To create a .wcl file."
  1010.   
  1011. To set a breakpoint in PerfectScript macros
  1012.  
  1013. 1    Click Tools  Macro  Debugger.
  1014.  
  1015. 2    Click Tools  Macro  Play.
  1016.  
  1017. 3    Enable the PerfectScript macro option.
  1018.  
  1019. 4    Type a filename in the Filename box.
  1020.  
  1021. 5    Click OK.
  1022.  
  1023. 6    In the Debugger dialog box, click Debug  Breakpoints  Edit.
  1024.  
  1025. 7    In the Edit breakpoints dialog box, click the Location and condition tab.
  1026.  
  1027. 8    Choose the type of breakpoint you want from the Type list box.
  1028.  
  1029. 9    Click one of the following buttons:
  1030.  
  1031.   Add-creates a new breakpoint
  1032.   
  1033.   Update-updates an existing breakpoint
  1034.   
  1035. Tip
  1036.  
  1037.   You can add a line number breakpoint by double-clicking the line in the macro source list where you want the macro to stop.
  1038.   
  1039. Customizing application settings using macros
  1040.  
  1041. As the application you create may affect standard settings on the desktop, it is a good idea to save and reset the user's environment settings. You can include extra code in the macro to restore the original settings once the user exits the application. You can also update links to other notebooks and objects using linking parameters.
  1042.  
  1043. You can customize macros using self-modifying (or dynamic) macro codes. Self-modifying macros either alter all or part of the macro when playing.
  1044.  
  1045. To save and reset application defaults
  1046.  
  1047. When you develop a Quattro Pro application, it is usually best to store the user's environment settings.
  1048.  
  1049. If you create a custom application in Quattro Pro that changes a user's environment settings, it is a good idea to include macro code that saves the user's current settings and restores them when the user exits the application. You can save the current settings with the following macro commands:
  1050.  
  1051. {LET:A1,PROPERTY("Application.Display")}
  1052.  
  1053. {LET:A2,PROPERTY("Application.International")}
  1054.  
  1055. {LET:A3,PROPERTY("Application.Macro")}
  1056.  
  1057. {LET:A4,PROPERTY("Application.File_Options")}
  1058.  
  1059. {LET:A5,PROPERTY("Application.General")}
  1060.  
  1061. To change the settings, you can use macro commands like the following:
  1062.  
  1063. {Application.Display "none,Yes,Yes,Yes,A..B:A1..B2,Yes,Yes,yes"}
  1064.  
  1065. {Application.International "$;Quattro Pro/Windows;Prefix;Signed;Windows Default;MM/DD/YY (MM/DD);HH:MM:SS (HH:MM);Quattro Pro;""English, North American (EN)"";No;Canada (English)'}
  1066.  
  1067. {Application.File_Options "H:\;;QPW;Yes;20;No;Yes;Yes;H:\Program Files\Corel\\Template\Custom QP Templates;20;No"}
  1068.  
  1069. {Application.Macro "Both;No;Quattro Pro - DOS;\0;No"}
  1070.  
  1071. {Application.General "Yes;No;Yes;Yes;500;No;Yes;Yes;Yes;Yes;Down"}
  1072.  
  1073. Finally, to restore the settings, use these macro commands:
  1074.  
  1075. {Application.Display +:A1}
  1076.  
  1077. {Application.International +:A2}
  1078.  
  1079. {Application.Macro +:A3}
  1080.  
  1081. {Application.File_Options +:A4}
  1082.  
  1083. {Application.General +:A5}
  1084.  
  1085. To use the active selection within a macro
  1086.  
  1087. PROPERTY("Active_Block.Selection") returns the address of the currently selected cells as an address and can be used within macro commands. The following macros set the print selection and create a named cell from the active cells: 
  1088.  
  1089. Print_Block    {Print.Block PROPERTY("Active_Block.Selection")}
  1090.  
  1091. Name_Blk    {BlockName.Create TestBlk", PROPERTY("Active_Block.Selection")}
  1092.  
  1093. To update links with macros
  1094.  
  1095. To pass linking parameters such as "Open Supporting," "Update References," or "None," you must spell out the entire parameter in the {FileOpen} macro command, as follows:
  1096.  
  1097. {FileOpen "TEST.QPW, "Open Supporting"}
  1098.  
  1099. {FileOpen "TEST.QPW, "Update References"}
  1100.  
  1101. {FileOpen "TEST.QPW, "None"}
  1102.  
  1103. To create self-modifying macros
  1104.  
  1105. You can use macro commands and text formulas to create self-modifying macros (also called dynamic macros) that alter themselves while playing. For example, to save the active notebook as acctx.qpw, where x is a value stored in cell A5, type the following text formula into a cell:
  1106.  
  1107. +"{FileSaveAs ""ACCT"&@STRING(A5,0)&".QPW""}"
  1108.  
  1109. The result of this formula plays as a macro command. For example, if cell A5 contains the value 5 from the previous example, Quattro Pro plays {FileSaveAs "ACCT5.QPW"}. If cell A5 changes to 10 and the notebook recalculates, Quattro Pro plays {FileSaveAs "ACCT10.QPW"}.
  1110.  
  1111. You can also use macro commands to change a portion of the macro while it is playing. The next example shows a macro that uses {GET} to convert user keystrokes into macro actions:
  1112.  
  1113. cell_type    b
  1114.  
  1115. type_indic    {INDICATE UPPER(CELLPOINTER("type"))}
  1116.  
  1117. {LET cell_type,cellpointer("type")}
  1118.  
  1119. {IF cell_type="l"}{INDICATE LABEL}
  1120.  
  1121. {IF cell_type="b"}{INDICATE BLANK}
  1122.  
  1123. {IF cell_type="v"}{INDICATE VALUE}{GET next_key}
  1124.  
  1125. {IF UPPER(next_key)="{ESC}"}{BRANCH clear_indic}
  1126.  
  1127. next_key    {Esc}{BRANCH type_indic}
  1128.  
  1129. clear_indic    {INDICATE}{QUIT}
  1130.  
  1131. You can use these concepts to create powerful macros that completely change themselves based on their environment.
  1132.  
  1133. Reference: Using macros
  1134.  
  1135. 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.
  1136.  
  1137. Additional macro resources
  1138.  
  1139. For a complete listing and category breakdown of available macro commands, see Quattro Pro Macros Help, which is located in the reference information section of the Quattro Pro online help.
  1140.  
  1141. For information about the list of available programming commands, see PerfectScript Programming Macros Help, which can be accessed from the WordPerfect Office Macro Command Center.
  1142.  
  1143. The WordPerfect Office Software Developer's Kit (SDK) is a set of tools that lets software developers customize WordPerfect Office applications for commercial or business use. The SDK includes the online Help for the SDK, OLE automation samples, PerfectScript tools, code generation wizards for third-party add-ons, utilities to monitor events, and a file format parsing tool. For information about acquiring a WordPerfect Office Software Developer's Kit, visit Corel Solutions Partners.
  1144.  
  1145. Choosing a macro creation tool
  1146.  
  1147. Quattro Pro provides several built-in scripting tools to create macros:
  1148.  
  1149.   Quattro Pro macros are stored in notebook cells. Use this type of macro when a task is performed within Quattro Pro.
  1150.   
  1151.   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."
  1152.   
  1153.   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 WordPerfect Office."
  1154.   
  1155. 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.
  1156.  
  1157. Comparing Quattro Pro macros with PerfectScript
  1158.  
  1159. Quattro Pro macros and PerfectScript use similar command syntax. There are, however, some major differences in the two scripting tools:
  1160.  
  1161.  
  1162.  
  1163. Quattro Pro macros    PerfectScript macros
  1164.  
  1165. Are stored in notebooks or cells    Are stored in .wcm macro files
  1166.  
  1167. Are created and edited in the notebook    Are created and edited in WordPerfect
  1168.  
  1169. Can be played from a library notebook     Are played from the source folder
  1170.  
  1171. Can use shortcut names for playing    Cannot play from shortcut names
  1172.  
  1173. Play only in Quattro Pro    Play in any WordPerfect Office application
  1174.  
  1175. Use blank lines to separate macros    Use blank lines to separate commands and subroutines
  1176.  
  1177. Use commands and arguments    Use commands and parameters (which contain arguments)
  1178.  
  1179.  
  1180.  
  1181. The following table presents the major syntactical differences between both macro tools: 
  1182.  
  1183.  
  1184.  
  1185. Quattro Pro syntax    PerfectScript syntax
  1186.  
  1187. Command has curly braces    No braces around command
  1188.  
  1189. No parentheses around argument list    Parentheses required around parameter list
  1190.  
  1191. Object and property separated by period    Object and property separated by underscore
  1192.  
  1193. Arguments separated by commas    Arguments separated by semicolons
  1194.  
  1195.  
  1196.  
  1197. Syntax examples of Quattro Pro macros
  1198.  
  1199. Quattro Pro macro syntax uses the following syntax format:
  1200.  
  1201. {CONTENTS E15, F15, G15}
  1202.  
  1203. 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}.
  1204.  
  1205. PerfectScript uses the following syntax format:
  1206.  
  1207. GraphGallery(GraphStyle:"3dbar";ColorScheme:"Tangerine")
  1208.  
  1209. The command name GraphGallery indicates the feature the command activates. This particular example launches the Chart Gallery and selects a 3-D 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.
  1210.  
  1211. For more information about Quattro Pro syntax, see "Macro syntax and arguments."
  1212.  
  1213. To get more information about recording and attaching macros to toolbars, notebooks, and controls, see "Using macros."
  1214.  
  1215. Understanding Quattro Pro macro syntax
  1216.  
  1217. Macro commands are like spreadsheet functions: they have specific grammatical rules, or syntax. The basic syntax is
  1218.  
  1219. {COMMANDNAME Argument1,Argument2, Argument3,...}
  1220.  
  1221. COMMANDNAME is the name of the command.
  1222.  
  1223. Arguments are values. Not all macro commands require arguments; when they do, they require a specific type of information.
  1224.  
  1225. The following are some examples of macro commands:
  1226.  
  1227. {Query.Criteria_Table B27..B29}
  1228.  
  1229. {BlockCopy A1,A2..A37}
  1230.  
  1231. {Search.Find "3rd Quarter Profits"}
  1232.  
  1233. {GETNUMBER "How old are you?",AGE}
  1234.  
  1235. {CONTENTS E15,F15,5}
  1236.  
  1237. Quattro Pro syntax requires that you type the entire macro command in a single cell. The following syntax rules for macro commands also apply:
  1238.  
  1239.  
  1240.  
  1241. QP syntax must include    Examples
  1242.  
  1243.   Opening and closing braces{}    {BEEP 3}
  1244.  
  1245. COMMANDNAME(space)Argument1    {BlockCopy A1}
  1246.  
  1247. Commas or semicolons between arguments    {CONTENTS E15,F15,5}
  1248.  
  1249. Correct argument types    {GETLABEL hello world, A4} where "hello world" is not a valid string type
  1250.  
  1251. Quotation marks around punctuation or spaces    {GETLABEL "Hello,world",A4}
  1252.  
  1253. Type command in upper/lower case    GETLABEL = getlabel
  1254.  
  1255. One or more commands for each cell    {BEEP}{GETLABEL "Hello, world",A4}{QUIT}
  1256.  
  1257.  
  1258.  
  1259. If a setting contains spaces, punctuation, or quotation marks, enclose it within double quotation marks (for example, "Prefix, ""Windows Default"",",No").
  1260.  
  1261. Understanding arguments
  1262.  
  1263. 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. 
  1264.  
  1265.  
  1266.  
  1267. Number arguments    Examples
  1268.  
  1269. Any numeric value, entered as a number     2 or 0.45
  1270.  
  1271. A formula resulting in a number    A3*15
  1272.  
  1273. A cell address with a numeric value or formula    C10, where C10 contains a number or formula
  1274.  
  1275. A named block with a numeric value or formula    C10, where C10 contains a valid number or formula
  1276.  
  1277. String arguments    Examples
  1278.  
  1279. A text string, such as an actual string     "Corel"
  1280.  
  1281. A reference to a cell or block containing a label    A1..A4
  1282.  
  1283. A property separated by a comma (,)    "Currency, 2" (This also applies to command settings separated by a comma)
  1284.  
  1285. A formula resulting in a label    @UPPER("hello ")
  1286.  
  1287.  
  1288.  
  1289. Location arguments    Examples
  1290.  
  1291. A block name    INTEREST refers to a cell block C5-C15
  1292.  
  1293. Block coordinates with more than one cell    A1,A1..A4 or A..B:C4..D22
  1294.  
  1295. 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)
  1296.  
  1297. Coordinates for noncontiguous blocks    (A1,B1..B7,C1..C7) or (A1,B:C27..C52)
  1298.  
  1299. A label or text formula in any of these options    +"A"&"2" which results in A2
  1300.  
  1301.  
  1302.  
  1303. Condition arguments    Examples
  1304.  
  1305. A formula that evaluates to true or false    +C4>500
  1306.  
  1307.  
  1308.  
  1309. 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.
  1310.  
  1311. 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:
  1312.  
  1313. {LET new_block,3+4:value}
  1314.  
  1315. {LET new_block,3+4:string}
  1316.  
  1317. For information about PerfectScript syntax, see "Choosing a macro creation tool."
  1318.  
  1319. For information about using relative cell references, see "Recording macros using relative and absolute cell references."
  1320.  
  1321. Integrating Visual Basic for Applications with WordPerfect Office
  1322.  
  1323. 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.
  1324.  
  1325. Event-driven programming
  1326.  
  1327. 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. 
  1328.  
  1329. The difference between PerfectScript and VBA 
  1330.  
  1331. 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.
  1332.  
  1333. The PerfectScript class
  1334.  
  1335. All product commands used in WordPerfect, Quattro Pro, and Corel 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 Corel Presentations have their own PerfectScript class because the class members, which are the product commands, are different depending on the application.
  1336.  
  1337. All members of the PerfectScript class perform a specific action. For more information about product commands, see the macros command list "QP MACRO LIST".
  1338.  
  1339. Note
  1340.  
  1341.   Although there may be some differences, the syntax for the product commands and the PerfectScript members is usually the same.
  1342.   
  1343.   Working in the VBA Editor
  1344.   
  1345.   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 Corel Presentations, the name of the document object is ThisSlideShow.
  1346.   
  1347.   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 located 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.
  1348.   
  1349.   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.
  1350.   
  1351.   Accessing an application from another application's macro
  1352.   
  1353.   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.
  1354.   
  1355.   Using VBA macros
  1356.   
  1357.   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.
  1358.   
  1359.   Assigning security
  1360.   
  1361.   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.
  1362.   
  1363.   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).
  1364.   
  1365.   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  Visual Basic  Security) and click the What's this Help.
  1366.   
  1367. Setting macro breakpoints
  1368.  
  1369. The following macro includes a loop that continuously increments a single cell called COUNTER.
  1370.  
  1371. counter        0
  1372.  
  1373. Is_done    +COUNTER>=100
  1374.  
  1375.  
  1376.  
  1377. \m    {LET counter,0}
  1378.  
  1379. again    {; increment counter}
  1380.  
  1381. {LET counter,counter+1}~
  1382.  
  1383. {BRANCH again}
  1384.  
  1385. 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.
  1386.  
  1387. 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.
  1388.  
  1389. 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. 
  1390.  
  1391. Example of a VBA project macro in Quattro Pro
  1392.  
  1393. 1    Click Tools  Visual Basic  Visual Basic Editor.
  1394.  
  1395. 2    In the Project Docker window double-click VBAProject (NoteBk) in the list of categories.
  1396.  
  1397. 3    Click Insert  User form.
  1398.  
  1399. 4    Modify the form so that it resembles the following diagram:
  1400.  
  1401.  
  1402.  
  1403. 5    Change the name of the TextBox control to NameBox as illustrated in the following list:
  1404.  
  1405. Command Button - CommandButton1
  1406.  
  1407. TextBox - NameBox
  1408.  
  1409. 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:
  1410.  
  1411. Private Sub CommandButton1_Click()
  1412.  
  1413. Dim myname, Msg As String
  1414.  
  1415. myname = NameBox
  1416.  
  1417. Msg = "Hello " & myname
  1418.  
  1419. MsgBox Msg
  1420.  
  1421. End
  1422.  
  1423. End Sub
  1424.  
  1425. This code responds to the event that occurs when the command button is clicked.
  1426.  
  1427. 7    Open the Quattro Pro objects folder in the Project Docker window.
  1428.  
  1429. 8    Double-click ThisNotebook.
  1430.  
  1431. 9    Type the following lines of code in the Notebk1 editor window:
  1432.  
  1433. Public Sub ShowForm()
  1434.  
  1435. End Sub
  1436.  
  1437. This code will add a new method to the ThisDocument class.
  1438.  
  1439. 10    Type the following line of code in the ShowForm method:
  1440.  
  1441. Public Sub ShowForm()
  1442.  
  1443. UserForm1.Show
  1444.  
  1445. End Sub
  1446.  
  1447. Note
  1448.  
  1449.   If you declare ShowForm as a private method, you will not be able to run the macro from Quattro Pro.
  1450.   
  1451. Tip
  1452.  
  1453.   You can change all of the control's attributes, including the name of the control, in the Properties docker window.
  1454.   
  1455. Example of a VBA macro that will manipulate a Quattro Pro document
  1456.  
  1457. 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.
  1458.  
  1459. 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.
  1460.  
  1461. 1    Open WordPerfect.
  1462.  
  1463. 2    Click Tools  Visual Basic  Visual Basic Editor.
  1464.  
  1465. 3    Double-click on Project (Document1) in the Project explorer Docker window.
  1466.  
  1467. 4    Click Tools  Reference.
  1468.  
  1469. 5    Enable the Corel - QuattroPro 9 type library check box.
  1470.  
  1471. 6    Click OK.
  1472.  
  1473. 7    Open the WordPerfect objects folder in the Project explorer Docker window.
  1474.  
  1475. 8    Double-click ThisDocument, and type the following line of code in the code module window:
  1476.  
  1477. Public Sub CreateQPTable()
  1478.  
  1479. End Sub
  1480.  
  1481. This code adds a new method to the ThisDocument class.
  1482.  
  1483. 9    Type the following lines of code in the CreateQPTable method:
  1484.  
  1485. Public Sub CreateQPTable()
  1486.  
  1487. Dim myQp as Object
  1488.  
  1489. Set myQp = CreateObject("QuattroPro.PerfectScript")
  1490.  
  1491.  
  1492.  
  1493. If myQp Is Nothing Then
  1494.  
  1495. MsgBox "The Quattro Pro Object is invalid", vbCritical
  1496.  
  1497. End If
  1498.  
  1499. 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.
  1500.  
  1501. 10    Type the following lines of code in the CreateQPTable method:
  1502.  
  1503. Public Sub CreateQPTable()
  1504.  
  1505.  
  1506.  
  1507. Dim myQp as Object
  1508.  
  1509. Set myQp = CreateObject("QuattroPro.PerfectScript")
  1510.  
  1511.  
  1512.  
  1513. If myQp Is Nothing Then
  1514.  
  1515. MsgBox "The Quattro Pro Object does not exist", vbCritical
  1516.  
  1517. End If
  1518.  
  1519.     
  1520.  
  1521. 'Populate the Quattro Pro document
  1522.  
  1523. myQp.FileNew "FileNew"
  1524.  
  1525. myQp.SetCellString "B1", "Jan"
  1526.  
  1527. myQp.SetCellString "C1", "Feb"
  1528.  
  1529. myQp.SetCellString "D1", "Mar"
  1530.  
  1531. myQp.SetCellString "A2", "TVs"
  1532.  
  1533. myQp.SetCellString "A3", "VCRs"
  1534.  
  1535. myQp.SetCellString "A4", "Radios
  1536.  
  1537.  
  1538.  
  1539. End Sub
  1540.  
  1541. This code creates a new Quattro Pro document and creates an inventory table. 
  1542.  
  1543. Notes
  1544.  
  1545.   Make sure that CreateQPTable is declared public so that you can access this macro from WordPerfect.
  1546.   
  1547.   Every application has an object. Make sure you reference the right object.
  1548.   
  1549. Example of using the PerfectScript class to change a Quattro Pro document
  1550.  
  1551. 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.
  1552.  
  1553. 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".
  1554.  
  1555.  
  1556.  
  1557. 1    Click Tools  Visual Basic  Visual Basic Editor.
  1558.  
  1559. 2    In the Project explorer Docker window, double-click VBAProject (NoteBk1)  Quattro Pro objects  ThisNotebook in the list of categories.
  1560.  
  1561. 3    Type the following lines of code in the Notebook1 code module window:
  1562.  
  1563. Public Sub AddInventory()
  1564.  
  1565. End Sub
  1566.  
  1567. This code adds a new method, called AddInventory, to the ThisDocument class.
  1568.  
  1569. 4    Type the following lines of code to create a private method called CreateTable:
  1570.  
  1571. Private Sub CreateTable()
  1572.  
  1573. PerfectScript.SetCellString "B1", "Jan"
  1574.  
  1575. PerfectScript.SetCellString "C1", "Feb"
  1576.  
  1577. PerfectScript.SetCellString "D1", "Mar"
  1578.  
  1579. PerfectScript.SetCellString "A2", "TVs"
  1580.  
  1581. PerfectScript.SetCellString "A3", "VCRs"
  1582.  
  1583. PerfectScript.SetCellString "A4", "Radios"
  1584.  
  1585. End Sub
  1586.  
  1587. This code creates an inventory table. 
  1588.  
  1589. 5    Type the following lines of code to create a private method called AddValues:
  1590.  
  1591. Private Sub AddValues()
  1592.  
  1593.  
  1594.  
  1595. 'Populate the January Column
  1596.  
  1597. PerfectScript.SelectBlock "B2"
  1598.  
  1599. PerfectScript.PutCell2 "200"
  1600.  
  1601. PerfectScript.SelectBlock "B3"
  1602.  
  1603. PerfectScript.PutCell2 "250"
  1604.  
  1605. PerfectScript.SelectBlock "B4"
  1606.  
  1607. PerfectScript.PutCell2 "350"
  1608.  
  1609.  
  1610.  
  1611. 'Populate the February Column
  1612.  
  1613. PerfectScript.SelectBlock "C2"
  1614.  
  1615. PerfectScript.PutCell2 "100"
  1616.  
  1617. PerfectScript.SelectBlock "C3"
  1618.  
  1619. PerfectScript.PutCell2 "280"
  1620.  
  1621. PerfectScript.SelectBlock "C4"
  1622.  
  1623. PerfectScript.PutCell2 "340"
  1624.  
  1625.  
  1626.  
  1627. 'Populate the March Column
  1628.  
  1629. PerfectScript.SelectBlock "D2"
  1630.  
  1631. PerfectScript.PutCell2 "150"
  1632.  
  1633. PerfectScript.SelectBlock "D3"
  1634.  
  1635. PerfectScript.PutCell2 "230"
  1636.  
  1637. PerfectScript.SelectBlock "D4"
  1638.  
  1639. PerfectScript.PutCell2 "490"
  1640.  
  1641. End Sub
  1642.  
  1643. This code adds numeric values to the inventory table.
  1644.  
  1645. 6    Type the following lines of code to create a private method called CalculateValues:
  1646.  
  1647. Private Sub CalculateValues()
  1648.  
  1649.  
  1650.  
  1651. 'Calculate the January totals
  1652.  
  1653. PerfectScript.SelectBlock "B2..B4"
  1654.  
  1655. PerfectScript.QuickFunction "SUM", "B5"
  1656.  
  1657.  
  1658.  
  1659. 'Calculate the February totals
  1660.  
  1661. PerfectScript.SelectBlock "C2..C4"
  1662.  
  1663. PerfectScript.QuickFunction "SUM", "C5"
  1664.  
  1665.  
  1666.  
  1667. 'Calculate the March totals
  1668.  
  1669. PerfectScript.SelectBlock "D2..D4"
  1670.  
  1671. PerfectScript.QuickFunction "SUM", "D5"
  1672.  
  1673.  
  1674.  
  1675. PerfectScript.SetCellString "A5", "Totals:"
  1676.  
  1677. End Sub
  1678.  
  1679. This code adds the values in each column.
  1680.  
  1681. 7    Type the following lines of code in the AddInventory method to call the private methods:
  1682.  
  1683. Public Sub AddInventory()
  1684.  
  1685. CreateTable
  1686.  
  1687. AddValues
  1688.  
  1689. CalculateValues
  1690.  
  1691. End Sub
  1692.  
  1693. This code calls all of the private methods that you created.
  1694.  
  1695. Notes
  1696.  
  1697.   If you declare AddInventory as a private method, you will not be able to run it from Quattro Pro.
  1698.   
  1699.   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.
  1700.   
  1701. Example of accessing the system's date and time values
  1702.  
  1703. 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 variables-myTime and myDate-into 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.
  1704.  
  1705. The following example creates a project macro.
  1706.  
  1707.  
  1708.  
  1709. 1    Click Tools  Visual Basic  Visual Basic Editor.
  1710.  
  1711. 2    In the Project explorer Docker window, double-click VBAProject (NoteBk1)  Quattro Pro objects  ThisNotebook in the list of categories.
  1712.  
  1713. 3    Type the following lines of code in the Notebook1 code module window:
  1714.  
  1715. Public Sub ShowTime()
  1716.  
  1717. End Sub
  1718.  
  1719. This code will add a new method to the ThisDocument class.
  1720.  
  1721. 4    Type the following new code in the ShowTime method to declare two new variables:
  1722.  
  1723. Public Sub ShowTime()
  1724.  
  1725. Dim myTime
  1726.  
  1727. Dim myDate As Date
  1728.  
  1729. End Sub
  1730.  
  1731. 5    Type the following new code in the ShowTime method to populate the myTime and the myDate variables:
  1732.  
  1733. Public Sub ShowTime()
  1734.  
  1735. Dim myTime
  1736.  
  1737. Dim myDate As Date
  1738.  
  1739. myTime = Time
  1740.  
  1741. myDate = Date
  1742.  
  1743. End Sub
  1744.  
  1745. 6    Type the following new code in the ShowTime method to convert the two variables to string data types:
  1746.  
  1747. Public Sub ShowTime()
  1748.  
  1749. Dim myTime
  1750.  
  1751. Dim myDate As Date
  1752.  
  1753. myTime = Time
  1754.  
  1755. myDate = Date
  1756.  
  1757.  
  1758.  
  1759. Dim myStrTime, myStrDate, Msg As String
  1760.  
  1761. myStrDate = Str(myDate)
  1762.  
  1763. myStrTime = Str(myTime)
  1764.  
  1765. End Sub
  1766.  
  1767. 7    Type the following new code in the ShowTime method to populate and display the Msg variable:
  1768.  
  1769. Public Sub ShowTime()
  1770.  
  1771. Dim myTime
  1772.  
  1773. Dim myDate As Date
  1774.  
  1775. myTime = Time
  1776.  
  1777. myDate = Date
  1778.  
  1779.  
  1780.  
  1781. Dim myStrTime, myStrDate, Msg As String
  1782.  
  1783. myStrDate = Str(myDate)
  1784.  
  1785. myStrTime = Str(myTime)    
  1786.  
  1787.  
  1788.  
  1789. Msg = "The date is " & myStrDate & " and the time is " & myStrTime
  1790.  
  1791. MsgBox Msg
  1792.  
  1793. End Sub
  1794.  
  1795. Notes
  1796.  
  1797.   Make sure that ShowTime is declared public so that you can access this macro from Quattro Pro.
  1798.   
  1799.   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.
  1800.   
  1801. Absolute and relative cell addresses
  1802.  
  1803. The following is an example of absolute and relative addressing:
  1804.  
  1805.   Absolute: []A:A1..D10
  1806.   
  1807.   Relative: []P(0):C(0)R(0)..C(4)R(10)
  1808.   
  1809. 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:
  1810.  
  1811.   Absolute: []$A:$A$1..$D$10
  1812.   
  1813.   Relative: [][]A:A1..D10
  1814.   
  1815. 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.
  1816.  
  1817. Relative references specify cells as offset from the cell selector. For example, the cell selector's relative reference is []P(0):C(0)R(0). 
  1818.  
  1819.  
  1820.  
  1821. Reference    Result
  1822.  
  1823. ([ ])    Specifies that you are referring to the active notebook
  1824.  
  1825. 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)
  1826.  
  1827. C(0)    Indicates the number of columns from the selector
  1828.  
  1829. R(0)    Indicates the number of rows from the selector
  1830.  
  1831.  
  1832.  
  1833. 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).
  1834.  
  1835. For more information about setting absolute and relative cell references, see "Setting cell addresses."
  1836.  
  1837. 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).
  1838.  
  1839. 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.
  1840.  
  1841. 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)}.
  1842.  
  1843. 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. 
  1844.  
  1845.  
  1846.  
  1847.  
  1848.