How You Can Index into an Undeclared Collection
The following code shows how to index into a collection when the collection has not been defined to OpenROAD as a collection:
initialize()=
declare
app = application;
wbs = workbooks;
x = integer;
y = varchar(20);
awbs = array of workbook;
enddeclare
begin
// Show Microsoft Excel
app.visible = 1;
// Get the workbooks collection
wbs = app.workbooks();
// Open a workbook and put it into an OpenROAD
// array
awbs[1] = wbs.open
('c:\msoffice\excel\examples\samples.xls');
// Index into the OpenROAD array to access a workbook
// and set an attribute.
awbs[1].author = 'John Smith';
// Index into the workbooks collection through an integer
// constant and set an attribute of the workbook
// being indexed.
Wbs.item(1).author = 'Jane Smith';
// Index into the workbooks collection through a string
// constant and set an attribute of the workbook
// being indexed.
wbs.item('samples.xls').author = 'Sam';
// Index into the workbooks collection through a varchar
// variable and set an attribute of the workbook
// being indexed.
x = 1;
wbs.item(x).author = 'Sally';
// Index into the workbooks collection through an integer
// variable and set an attribute of the workbook
// being indexed.
y = 'samples.xls';
wbs.item(y).author = 'unknown';
// Index into the workbooks collection through a string
// constant and call a method of the workbook being
// indexed.
wbs.item('samples.xls').close(TRUE,'c:\save.xls',FALSE);
// Quit Excel.
app.quit();
end
Last modified date: 06/25/2024