'引用Microsoft Excel X.0 Object Library Private Sub Command1_Click() Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xSheet As Excel.Worksheet Set xlApp = New Excel.Application Set xlBook = xlApp.Workbooks.Open("C:\Book1.xls") Set xSheet = xBook.Worksheets(1) xlApp.Visible=True '..... xlBook.Close False xlApp.Quit Set xlBook = Nothing Set xlApp = Nothing end sub
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xSheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("C:\Book1.xls")
Set xSheet = xBook.Worksheets(1)
xlApp.Visible=True
'.....
xlBook.Close False
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
end sub