|
Dim wj1, wj2
Dim x, y As Integer
Dim dd As QueryDef
CurrentDb.Execute ("drop table dd1")
b3 = "TRANSFORM max([人数]) SELECT 1 FROM (SELECT [班级], Count(*) AS 人数 FROM b1 WHERE [总分]>= " & [Forms]![主窗体]![Txtone] & " GROUP BY [班级] ) GROUP BY 1 PIVOT [班级] & '班'"
Set dd = CurrentDb.CreateQueryDef("dd1", b3)
path = CurrentProject.path
b1 = "模板.xls"
b2 = "表1.xls"
wj1 = path & "\" & b1
wj2 = path & "\" & b2
FileCopy wj1, wj2
Set myxl = GetObject(wj2, "excel.sheet")
myxl.Application.Visible = False
myxl.Parent.windows(1).Visible = True
rst.Open "dd1", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
myxl.Sheets(1).Range("a2").CopyFromRecordset rst
MsgBox "导出完毕"
myxl.Save
myxl.Application.Quit
Set myxl = Nothing
将XLS文件中第1列删除即可 |
|