Getting Data from Excel

To access the information in an Excel cell, use the Value property of the cell object and store the result in a variable or pass it directly to Visio as in Listing 21.2.

Listing 21.2. Getting an Excel Cell's Value
 Public Sub GrabFromExcel() Dim shpObj As Visio.Shape Dim celObj As Visio.Cell Dim xlObjApp As Excel.Application Dim xlObjBook As Excel.Workbook Dim xlObjSheet As Excel.Worksheet Dim xlObjCell As Excel.Range Set shpObj = Visio.ActiveWindow.Selection.Item(1) Set celObj = shpObj.Cells("Prop.Duration") Set xlObjApp = GetObject(, "Excel.Application") Set xlObjBook = xlObjApp.Workbooks.Item("TestCase.XLS") Set xlObjSheet = xlObjBook.Worksheets.Item("Sheet1") Set xlObjCell = xlObjSheet.Range("C3") xlObjCell.Select ...

Get Professional Development with Visio® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.