258 Chapter 6
Creating Reports Easily Using ActiveX
Sending Agilent VEE Data to MS Excel
The commands in the Formula object Set Up Excel Worksheet are as
follows:
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.)