User`s guide
258 VEE User’s Guide
6 Creating Reports Easily Using ActiveX Chapter
Table 2 5 Setting up an Excel Worksheet in the Formula Object
Command Description
set sheet = The keyword set is used to assign or set whatever is on the
right-hand side of the assignment operator (in this case, the
equal sign) to the variable on the left-hand side of the
expression. For example, set app sets the application
sheet.application, which has been defined as an Excel
worksheet.
CreateObject
(“Excel.Sheet”).
Creates a new instance of the Automation Server (in this
case, MS Excel) and creates an empty sheet (Excel
terminology for a new workbook). Each Automation Server
has its own terminology, but the syntax is the same. For
example, to create a report in MS Word, you would enter
CreateObject(“Word.Document”) to run
Word and create a blank document.
If the set keyword is used, the right-hand side object pointer
itself is assigned to the left-hand side variable. If set is not
used, then the default property (often the name) of the
right-hand side is assigned to the left-hand side. For more
information, refer to the VEE Pro Advanced Techniques
manual.
worksheets(1); Now that Excel is running with a new workbook in it, with
CreateObject("Excel.Sheet"), you want to address the
first worksheet in it. Add
worksheets(1) to the
statement, so the entire statement reads:
setsheet =
CreateObject("Excel.Sheet").worksheets(1);
This sets sheet to Sheet 1 of the report. (To see an example,
open MS Excel and select File ⇒ New to create a new
workbook. You will notice there are several sheets in it
labeled Sheet1, Sheet2, and so on. You want Sheet1.)
set app =
sheet.application;
Asks Excel for a pointer to the entire application, and not
just the worksheet itself, by asking the worksheet for its
property Application and setting it to the variable app.
app.visible = true; Sets the app’s visible property to true in order to display
Excel on screen (so that you can see it).