- 积分
- 370
- 明经币
- 个
- 注册时间
- 2008-3-20
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
调用EXCEL数据 做的工具栏 打开CAD第一次可以正常使用 第二次就不行了 但是在VBA里 可以正常的调试 为什么啊?
Option Explicit
Dim TXDH(131, 42) As String
Dim i, j As Integer
Private Sub UserForm_Initialize()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strpath, strName As String
strpath = ThisDrawing.Application.VBE.activevbproject.FileName
strName = Left(strpath, Len(strpath) - 4) & ".xls" 'EXCEL文件名
Set xlApp = CreateObject("Excel.application")
Set xlBook = Workbooks.Open(strName)
Set xlSheet = xlBook.Worksheets("TX")
For i = 2 To 130
For j = 1 To 42
TXDH(i, j) = xlSheet.Cells(i, j)
Next j
ComboBox1.AddItem TXDH(i, 1)
Next i
xlBook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
|
|