- 积分
- 142
- 明经币
- 个
- 注册时间
- 2011-11-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Public Function guimianshejigaocheng()
Dim excelApp As Excel.Application
Dim excelSheet As Excel.Worksheet
Dim strFile As String
strFile = ThisDrawing.Application.VBE.ActiveVBProject.fileName
Set excelApp = CreateObject("Excel.Application")
excelApp.Visible = False
excelApp.Workbooks.Open Left$(strFile, Len(strFile) - Len("ex01.dvb")) & "\Excel\demo.xls"
Set excelSheet = excelApp.ActiveWorkbook.Sheets("Sheet1")
Dim text As AcadText
Dim i As Integer, k As Integer
For i = 2 To 111
Dim a As Variant, e As String
a = Cells(i, 3).Value
e = a
k = 910 + 1.5 + (i - 1) * 10
Dim insert(0 To 2) As Double
insert(0) = k - 12
insert(1) = 245 - 4 + 35 - 2.5 + 10
insert(2) = 0
Dim textobj As AcadText
Set textobj = ThisDrawing.ModelSpace.AddText(e, insert, 2)
textobj.Rotation = 3.14159 / 2
Next i
' 退出Excel应用程序
excelApp.Quit
End Function
我用这段代码标注里程,现在问题是每次我都需要给一个循环范围,有没有办法让vba读到最后一条记录自动停止?
|
|