LOTUSSCRIPT LANGUAGE
For example, Microsoft Visio is a Windows drawing package that supports OLE automation. The following example builds an array of strings. Each string contains the name and job title of a manager on a Visio organizational chart.
In the module declarations, declare a dynamic one-dimensional array of strings:
Dim manager() As String
The GetManagers sub uses the CreateObject function to create an instance of the Visio Application class, which runs a new instance of the Visio program (VISIO.EXE). To get an instance that is already running, use the GetObject function.
A Visio Application object contains a collection of documents. Each document contains a collection of pages, and each page contains a collection of shapes. Visio provides a class for each of these: Application, Documents, Document, Pages, Page, Shapes, and Shape.
GetManagers uses the Documents class Open method to open a drawing file, a Document object. The sub then cycles through the pages in the document and the shapes on each page. For each shape with "Manager" in its Name property, the sub places the Text property value in a new element of the array. The Text property for a Manager shape contains a manager’s name and job title.
Sub GetManagers ' Use Variant variables for objects Dim appVisioV As Variant, docObjV As Variant Dim shapesObjV As Variant, shapeObjV As Variant Dim orgchart As String Dim iPage As Integer, iShape As Integer, _ iManager As Integer Set appVisioV = CreateObject("visio.application") orgchart$ = "c:\visio\drawings\orgchart.vsd" Set docObjV = appVisioV.Documents.Open(orgchart$) For iPage% = 1 To docObjV.Pages.Count Set shapesObjV = docObjV.Pages.Item(iPage%).Shapes For iShape% = 1 To shapesObjV.Count Set shapeObjV = shapesObjV.Item(iShape%) If Instr(shapeObjV.Name, "Manager") > 0 Then iManager% = iManager% + 1 ReDim Preserve manager$(1 To iManager%) manager$(iManager%) = shapeObjV.Text End If Next iShape% Next iPage% appVisioV.Quit End Sub
To display the contents of the array, use:
For i% = 1 To Ubound(manager$) Print manager$(i%) Next
For information about Visio classes, including their properties and methods, see the Visio documentation.
See Also