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

  1. Document.BeforeSave()
  2.  
  3. Syntax
  4.  
  5. Private Sub Document_BeforeSave()
  6.  
  7. Description
  8.  
  9. This event is called just before the Quattro Pro notebook is saved. This gives you a chance to customize your Quattro Pro notebook before you save it.
  10.  
  11. Example
  12.  
  13. In the following example, the numeric values are added and the result is written to the appropriate cell.
  14.  
  15. Private Sub Document_BeforeSave()
  16.  
  17.  
  18.  
  19. '*** Calculate the January totals
  20.  
  21. PerfectScript.SelectBlock "B2 B4"
  22.  
  23. PerfectScript.QuickFunction "SUM", "B5"
  24.  
  25.  
  26.  
  27. '*** Calculate the February totals
  28.  
  29. PerfectScript.SelectBlock "C2 C4"
  30.  
  31. PerfectScript.QuickFunction "SUM", "C5"
  32.  
  33.  
  34.  
  35. '*** Calculate the March totals
  36.  
  37. PerfectScript.SelectBlock "D2 D4"
  38.  
  39. PerfectScript.QuickFunction "SUM", "D5"
  40.  
  41. PerfectScript.SetCellString "A5", "Tot
  42.  
  43.  
  44.  
  45. End Sub
  46.  
  47. Note
  48.  
  49.   The code which created the inventory table is entered in the Document.AfterOpen().
  50.   
  51. Document.AfterSave()
  52.  
  53. Syntax
  54.  
  55. Private Sub Document_AfterSave()
  56.  
  57. Description
  58.  
  59. This event is called after you have saved your Quattro Pro notebook.
  60.  
  61. Example
  62.  
  63. In the following code fragment, a Message Box appears with the time and date. This data can be stored to a database which keeps track of file activities.
  64.  
  65. Private Sub Document_AfterSave()
  66.  
  67. '*** Declare all variables
  68.  
  69. Dim myTime
  70.  
  71. Dim myDate As Date
  72.  
  73. Dim myStrTime, myStrDate, Msg As String
  74.  
  75.  
  76.  
  77. '**** Populate the variables
  78.  
  79. myTime = Time
  80.  
  81. myDate = Date
  82.  
  83.  
  84.  
  85. myStrDate = Str(myDate)
  86.  
  87. myStrTime = Str(myTime)
  88.  
  89.  
  90.  
  91. '*** Display the Message Box
  92.  
  93. Msg = "The date is " & myStrDate & " and the time is " & myStrTime
  94.  
  95. MsgBox Msg
  96.  
  97. End Sub
  98.  
  99. Document. BeforeClose()
  100.  
  101. Syntax
  102.  
  103. Private Sub Document_BeforeClose()
  104.  
  105. Description
  106.  
  107. This event is called when the Quattro Pro notebook is closed; however, this code is executed before the notebook is actually closed.
  108.  
  109. Example
  110.  
  111. In the following code example, a Message Box will inform the user that the Quattro Pro notebook will close. This Message Box will appear before the notebook is closed.
  112.  
  113. Private Sub Document_BeforeClose()
  114.  
  115. MsgBox "You are about to close this document"
  116.  
  117. End Sub
  118.  
  119. Document.AfterOpen()
  120.  
  121. Syntax
  122.  
  123. Private Sub Document_AfterOpen()
  124.  
  125. Description
  126.  
  127. This event is called when the Quattro Pro document opens.
  128.  
  129. Example
  130.  
  131. You can customize your Quattro Pro notebook by adding a table. When the notebook opens, the following code will produce an inventory table:
  132.  
  133. Private Sub Document_AfterOpen()
  134.  
  135. '******* Create a Table
  136.  
  137. PerfectScript.SetCellString "B1", "Jan"
  138.  
  139. PerfectScript.SetCellString "C1", "Feb"
  140.  
  141. PerfectScript.SetCellString "D1", "Mar"
  142.  
  143. PerfectScript.SetCellString "A2", "TVs"
  144.  
  145. PerfectScript.SetCellString "A3", "VCRs"
  146.  
  147. PerfectScript.SetCellString "A4", "Radios"
  148.  
  149.  
  150.  
  151. '****** Populate the January Column
  152.  
  153. PerfectScript.SelectBlock "B2"
  154.  
  155. PerfectScript.PutCell2 "200"
  156.  
  157. PerfectScript.SelectBlock "B3"
  158.  
  159. PerfectScript.PutCell2 "250"
  160.  
  161. PerfectScript.SelectBlock "B4"
  162.  
  163. PerfectScript.PutCell2 "350"
  164.  
  165.  
  166.  
  167. '****** Populate the February Column
  168.  
  169. PerfectScript.SelectBlock "C2"
  170.  
  171. PerfectScript.PutCell2 "100"
  172.  
  173. PerfectScript.SelectBlock "C3"
  174.  
  175. PerfectScript.PutCell2 "280"
  176.  
  177. PerfectScript.SelectBlock "C4"
  178.  
  179. PerfectScript.PutCell2 "340"
  180.  
  181.  
  182.  
  183. '*** Populate the March Column
  184.  
  185. PerfectScript.SelectBlock "D2"
  186.  
  187. PerfectScript.PutCell2 "150"
  188.  
  189. PerfectScript.SelectBlock "D3"
  190.  
  191. PerfectScript.PutCell2 "230"
  192.  
  193. PerfectScript.SelectBlock "D4"
  194.  
  195. PerfectScript.PutCell2 "490"
  196.  
  197. End Sub
  198.  
  199.  
  200.  
  201. VBA Programming Issues Relating to Macro Commands
  202.  
  203. There are several issues that must be discussed with respect to programming with product commands in the VBA environment. You can click on any of the following gray boxes for a detailed explanation: 
  204.  
  205.  
  206.  
  207.     Product commands with Repeating Parameters
  208.  
  209.     Product commands that require a VARIABLE
  210.  
  211. Product commands with repeating parameters
  212.  
  213. To use product commands in VBA with repeating parameters, you must declare an array. Values for each repetitive parameter must be loaded into the array. After the array is populated, you have to pass the array The following list is all the macro commands in Quattro Pro with repeating parameters:
  214.  
  215. Product commands with repeating parameters:
  216.  
  217.     ExecAuto
  218.  
  219.     DLL
  220.  
  221.     Delvar
  222.  
  223.     SelectFloat
  224.  
  225.     SelectObject
  226.  
  227.     CrossTab
  228.  
  229.     GraphView
  230.  
  231.     CreateObject
  232.  
  233.     Code Example
  234.  
  235. Working with repeating parameters
  236.  
  237. You must create and pass an array to each product command that has repeating parameters. Refer to the following code example, which illustrates how to use PreTaskBar:
  238.  
  239. Example 1
  240.  
  241. '***** Create the variables
  242.  
  243. Dim boxes As Variant
  244.  
  245. Dim widths As Variant
  246.  
  247. Dim textIcon As Variant
  248.  
  249.  
  250.  
  251. '****** Populate each array
  252.  
  253. boxes = Array(7, 9, 2, 4, 10, 5)
  254.  
  255. textIcon = Array(0, 0, 0, 0, 0, 0)
  256.  
  257. widths = Array(50, 75, 50, 20, 100, 50)
  258.  
  259.  
  260.  
  261. '****** Pass each array
  262.  
  263. PerfectScript.PrefTaskBar boxes, textIcon, widths
  264.  
  265. Example 2
  266.  
  267. ****** Populate each array
  268.  
  269. PerfectScript.PrefTaskBar Array(7, 9, 2, 4, 10, 5),Array(0, 0, 0, 0, 0, 0),Array(50, 75, 50, 20, 100, 50) 
  270.  
  271. Code Explanation
  272.  
  273. You must define the box style, the icon style, and the width for every item that you want to appear on the application bar. In the example above, there are six elements in each array, meaning that six items will appear on the application bar. Each element corresponds to the item. The boxes array defines the box style for each item. All values in the textIcon array are 0, meaning there will be no icons in any of the items. The values in the widths array specifies the width for each item Notice that PreTaskBar has boxes, textIcon, and widths as arguments.
  274.  
  275. In the second example, all the Arrays were populated during the product command call. The benefit of this method is it decreases the lines of code in your macro.
  276.  
  277. Note
  278.  
  279.   You must use the integer values when populating an array used for repeating parameters.
  280.   
  281.  
  282.  
  283. Presentations product commands that use a VARIABLE as a parameter
  284.  
  285. You must use a Variant for any product command that requires a variable as a parameter. The Variant data type is the data type for all variables that are not  declared as another specific type. If you do not declare the variable as a Variant, then your VBA macro will not function properly . The following list is all the product commands which use a Variable as a parameter:
  286.  
  287.  
  288.  
  289. Product commands that use a VARIABLE as a parameter:
  290.  
  291.     PutCell2
  292.  
  293.     Let
  294.  
  295.     Put
  296.  
  297.     FloatCreate
  298.  
  299.     PutCell
  300.  
  301.     RecalcCol
  302.  
  303.     Random
  304.  
  305.     PutBlock2
  306.  
  307.     ReCalc
  308.  
  309.     PutBlock
  310.  
  311.     Code Example
  312.  
  313. Working with product commands that use a Variable
  314.  
  315. You must declare a variable that you pass to a product command as a Variant.
  316.  
  317. Refer to the following code fragment:
  318.  
  319.  
  320.  
  321. '**** Declare the variable
  322.  
  323. Dim myAnswer As Variant
  324.  
  325.  
  326.  
  327. '*** Pass the variable to DirectoryExists()
  328.  
  329. PerfectScript.DirectoryExists myAnswer, "D:\Client"
  330.  
  331. MsgBox myAnswer
  332.  
  333. Code Explanation
  334.  
  335. A Boolean value is returned to myAnswer. If the directory exists, then myAnswer will be assigned the value True. If the directory does not exist, then myAnswer will be assigned False. 
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.