本帖最后由 作者 于 2009-2-5 21:53:12 编辑
Public Sub GetDataFromXLS()
Dim ExcelSheet As Object Dim cell As Range Dim Excelobj As Excel.Application Dim ExcelWorkbook As Object Dim pt(0 To 2) As Double '创建Excel应用程序实例 On Error Resume Next Set Excelobj = GetObject(, "Excel.Application") If Err <> 0 Then Set Excelobj = CreateObject("Excel.Application") End If Set ExcelWorkbook = Excel.Workbooks.Open("c:\11.xls") '假设你的数据存在C盘11.xls文件里 Set ExcelSheet = Excelobj.ActiveSheet Set cell = ExcelSheet.cell For j = 0 To 9 '假设你有10行坐标,且从第2行开始 pt(0) = ExcelSheet.Cells(j + 2, 1).Value pt(1) = ExcelSheet.Cells(j + 2, 2).Value ThisDrawing.ModelSpace.AddCircle pt, 2 Next j '显示Excel工作表 Excelobj.Visible = True '关闭文件 ExcelWorkbook.Close SaveChanges:=False '关闭Excel应用程序 Excel.Application.Quit '删除Excel应用程序实例 Set Excelobj = Nothing End Sub 电子表格截图:
|