Dim xlApp As New Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    
    Dim i, j As Long
    Dim strTest As String
    
    
    Set xlBook = xlApp.Workbooks.Open("C:\test.xls")
    Set xlSheet = xlBook.Worksheets("sheet1")
    ……

解决方案 »

  1.   

    你没有引用EXCEL对象
    MicroSoft EXCEL 9.0 Object Library 必须先引用
      

  2.   

    那就xlsapp=createobject("excel.application")
      

  3.   

    'exl 唯一excel的app对象
    On Error Resume Next '忽略错误
        Set exl = GetObject(, "Excel.Application") '查找一个正在运行的Excel拷贝
        If Err.Number <> 0 Then '如果 Excel 没有运行则
        Set exl = CreateObject("Excel.Application") '运行它
        End If
        Err.Clear '清除发生错误的 Err 对象
        On Error GoTo 0 '保留普通错误进程
      

  4.   

    打开的excel文件一闪就消失了?怎么回事?