代码如下:
Private Sub 导出_Click()
Dim oApp As Object
Dim oappwork As Excel.Workbook, oappwork_sheet1 As Excel.Worksheet
Set oApp = CreateObject("Excel.Application")
oApp.Visible = False
Set oappwork = oApp.Workbooks.Open("H:\结果.xls")
Set oappwork_sheet1 = oappwork.Worksheets("sheet1")
With Me.查询子窗体.Form.Recordset
.MoveFirst
nn = .Fields.Count
j = 24
Do
If .EOF Then
Exit Do
Else
For i = 1 To nn - 7
oappwork_sheet1.cells(j, 0 + i) = .Fields(i + 3)
Next i
j = j + 1
.MoveNext
End If
Loop
MsgBox "报表已经导入EXCEL", vbOKOnly + vbInformation
oApp.Visible = True
On Error Resume Next