A. 引用EXCEL
B.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim Rs As DAO.Recordset
Dim ExcelFile as String
ExcelFile=CurrentProject.Path & "\Sample.xls"
Set xlApp = CreateObject("Excel.Application")
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open(Me.ExcelFile)
Set Rs=Currentdb.OpenRecordset("Select * from SampleQuery")
With xlBook
.Range("A1")=Rs("Sample")
End With
A. 引用EXCEL
B.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim Rs As DAO.Recordset, i as Integer
Dim ExcelFile as String
ExcelFile=CurrentProject.Path & "\Sample.xls"
Set xlApp = CreateObject("Excel.Application")
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open(Me.ExcelFile)
Set xlSheet=xlBook.WorkSheets(1)
Set Rs=Currentdb.OpenRecordset("Select * from SampleQuery")
i=1
While Not Rs.EOF
With xlSheet
.Range("A" & i)=Rs("Sample")
End With
i=i+1
Rs.MoveNext
Wend