Was this helpful?
How You Can Index into a Declared Collection
The following code shows how to index into a collection when the collection has been defined to OpenROAD as a collection:
initialize()=
declare
        app = application;
        wbs = workbooks collection of workbook;
        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.
        [1].author = 'John Smith';

//      Index into the workbooks collection through an integer
//      constant and set an attribute of the workbook
//      being indexed.
        wbs[1].author = 'Jane Smith';
//      Index into the workbooks collection through a string
//      constant and set an attribute of the workbook
//      being indexed.
        wbs['samples.xls'].author = 'Sam';

//      Index into the workbooks collection through an integer
//      variable and set an attribute of the workbook
//      being indexed.
        x = 1;
        wbs[x].author = 'Sally';
//      Index into the workbooks collection through a varchar
//      variable and set an attribute of the workbook
//      being indexed.
        y = 'samples.xls';
        wbs[y].author = 'unknown';

//      Index into the workbooks collection through a string
//      constant and call a method of the workbook being
//      indexed.
        wbs['samples.xls'].close(TRUE,'c:\save.xls',FALSE);

//      Quit Excel.
        app.quit();
end
In the preceding code, the Workbooks method returns a Workbooks collection of Workbook objects. The following sections show various ways of indexing into this collection.
Last modified date: 06/25/2024