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.
Example
In the following example, the numeric values are added and the result is written to the appropriate cell.
Private Sub Document_BeforeSave()
'*** Calculate the January totals
PerfectScript.SelectBlock "B2 B4"
PerfectScript.QuickFunction "SUM", "B5"
'*** Calculate the February totals
PerfectScript.SelectBlock "C2 C4"
PerfectScript.QuickFunction "SUM", "C5"
'*** Calculate the March totals
PerfectScript.SelectBlock "D2 D4"
PerfectScript.QuickFunction "SUM", "D5"
PerfectScript.SetCellString "A5", "Tot
End Sub
Note
The code which created the inventory table is entered in the Document.AfterOpen().
Document.AfterSave()
Syntax
Private Sub Document_AfterSave()
Description
This event is called after you have saved your Quattro Pro notebook.
Example
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.
Private Sub Document_AfterSave()
'*** Declare all variables
Dim myTime
Dim myDate As Date
Dim myStrTime, myStrDate, Msg As String
'**** Populate the variables
myTime = Time
myDate = Date
myStrDate = Str(myDate)
myStrTime = Str(myTime)
'*** Display the Message Box
Msg = "The date is " & myStrDate & " and the time is " & myStrTime
MsgBox Msg
End Sub
Document. BeforeClose()
Syntax
Private Sub Document_BeforeClose()
Description
This event is called when the Quattro Pro notebook is closed; however, this code is executed before the notebook is actually closed.
Example
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.
Private Sub Document_BeforeClose()
MsgBox "You are about to close this document"
End Sub
Document.AfterOpen()
Syntax
Private Sub Document_AfterOpen()
Description
This event is called when the Quattro Pro document opens.
Example
You can customize your Quattro Pro notebook by adding a table. When the notebook opens, the following code will produce an inventory table:
Private Sub Document_AfterOpen()
'******* Create a Table
PerfectScript.SetCellString "B1", "Jan"
PerfectScript.SetCellString "C1", "Feb"
PerfectScript.SetCellString "D1", "Mar"
PerfectScript.SetCellString "A2", "TVs"
PerfectScript.SetCellString "A3", "VCRs"
PerfectScript.SetCellString "A4", "Radios"
'****** Populate the January Column
PerfectScript.SelectBlock "B2"
PerfectScript.PutCell2 "200"
PerfectScript.SelectBlock "B3"
PerfectScript.PutCell2 "250"
PerfectScript.SelectBlock "B4"
PerfectScript.PutCell2 "350"
'****** Populate the February Column
PerfectScript.SelectBlock "C2"
PerfectScript.PutCell2 "100"
PerfectScript.SelectBlock "C3"
PerfectScript.PutCell2 "280"
PerfectScript.SelectBlock "C4"
PerfectScript.PutCell2 "340"
'*** Populate the March Column
PerfectScript.SelectBlock "D2"
PerfectScript.PutCell2 "150"
PerfectScript.SelectBlock "D3"
PerfectScript.PutCell2 "230"
PerfectScript.SelectBlock "D4"
PerfectScript.PutCell2 "490"
End Sub
VBA Programming Issues Relating to Macro Commands
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:
Product commands with Repeating Parameters
Product commands that require a VARIABLE
Product commands with repeating parameters
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:
Product commands with repeating parameters:
ExecAuto
DLL
Delvar
SelectFloat
SelectObject
CrossTab
GraphView
CreateObject
Code Example
Working with repeating parameters
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:
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.
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.
Note
You must use the integer values when populating an array used for repeating parameters.
Presentations product commands that use a VARIABLE as a parameter
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:
Product commands that use a VARIABLE as a parameter:
PutCell2
Let
Put
FloatCreate
PutCell
RecalcCol
Random
PutBlock2
ReCalc
PutBlock
Code Example
Working with product commands that use a Variable
You must declare a variable that you pass to a product command as a Variant.
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.