Adodc1.Recordset.MoveNext Loop
Text3.Text = Val(sum) '保存到text1中去 Adodc1.Recordset.MoveFirst Adodc1.Refresh
Dim SaveFile As String
Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
Adodc1.RecordSource = "select * from 员工基本信息表 where 员工编号 like '%" & Text2.Text & "%' and 姓名 like '%" & Text1.Text & "%'and 婚姻状况 like '%" & Combo1.Text & "%'and 性别 like '%" & Combo6.Text & "%' and 职位 like '%" & Combo2.Text & "%' and 政治面貌 like '%" & Combo3.Text & "%' and 所在部门 like '%" & Combo5.Text & "%'and 学历 like '%" & Combo4.Text & "%' " Adodc1.Refresh
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Add '打开已经存在的EXCEL工件簿文件
xlApp.Visible = True '设置EXCEL对象可见(或不可见) Set xlSheet = xlBook.Worksheets("Sheet1") '设置活动工作表 xlSheet.Cells(1, 1) = "员工编号" xlSheet.Cells(1, 2) = "姓名" xlSheet.Cells(1, 3) = "年龄" xlSheet.Cells(1, 4) = "性别" xlSheet.Cells(1, 5) = "所在部门" xlSheet.Cells(1, 6) = "电话" xlSheet.Cells(1, 7) = "职位" xlSheet.Cells(1, 8) = "学历" xlSheet.Cells(1, 9) = "聘用时间" xlSheet.Cells(1, 10) = "离职时间" xlSheet.Cells(1, 11) = "婚姻状况" xlSheet.Cells(1, 12) = "政治面貌" xlSheet.Cells(1, 13) = "毕业学校" xlSheet.Cells(1, 14) = "籍贯" xlSheet.Cells(1, 15) = "民族" For j = 1 To sum
xlSheet.Cells(j + 1, 1) = Adodc1.Recordset.Fields(0) xlSheet.Cells(j + 1, 2) = Adodc1.Recordset.Fields(1)