先在工程中选中 Ms 9.0 excel object ,即对EXCEL的引用
Dim xlApp As Excel.Application
Dim wbzhishu As Excel.Workbook
Dim shtzhishu As Excel.Worksheet On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlApp = CreateObject("Excel.Application")
End If
Err.Clear
Set wbzhishu = xlApp.Workbooks.Open(filename1)
Set shtzhishu = wbzhishu.Sheets("sheet2")
Dim xlApp As Excel.Application
Dim wbzhishu As Excel.Workbook
Dim shtzhishu As Excel.Worksheet On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set xlApp = CreateObject("Excel.Application")
End If
Err.Clear
Set wbzhishu = xlApp.Workbooks.Open(filename1)
Set shtzhishu = wbzhishu.Sheets("sheet2")
[email protected]