Ailen. 发表于 2011-10-19 22:40:03

excel和cad关联不上

Private Sub dc_Click()
On Error Resume Next

'''''''''''''''''''''''''''''''''''''''''''''''''''
Dim p As Integer
p = x.ListCount

Me.Hide
    ' 显示打开文件对话框
    CommonDialog1.filter = "梁表 (*.xls)|*.xls|梁表 (*.xls)|*.xls"
    CommonDialog1.FilterIndex = 1
    CommonDialog1.ShowOpen
    '''打开所要打开的梁表EXCL文件
    'TextBox11.Text = CommonDialog1.FileName
    Dim excelApp As Excel.Application
    Dim excelSheet As Excel.Worksheet
   
    Dim filepathandFileName As String
    filepathandFileName = CommonDialog1.FileName
   
   
    ' 获得当前工程的路径
    Dim strFile As String
    strFile = ThisDrawing.Application.VBE.ActiveVBProject.FileName
   
    ' 运行Excel应用程序
    Set excelApp = CreateObject("Excel.Application")
    excelApp.Visible = True
   
    ''打开指定路径中的EXCLE表格
      excelApp.Workbooks.Open filepathandFileName
      
Set excelSheet = excelApp.ActiveWorkbook.Sheets("一点放样表")

Dim n As Integer
For n = 0 To p

excelSheet.Cells(n + 1, 1).Value = x.List(p - n)
excelSheet.Cells(n + 1, 2).Value = yy.List(p - n)
excelSheet.Cells(n + 1, 6).Value = zh1.List(p - n)


Next






   
   
   
    Me.Show vbModeless


End Sub
这段代码谁帮我看看怎么和cad连不上了啊
页: [1]
查看完整版本: excel和cad关联不上