|
不会吧?我试了一下可以。你看看实例中A到E的代码。
Private Sub A到E_Click()
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim i As Long
xlApp.Application.Visible = True
Set xlBook = xlApp.Workbooks.Open(CurrentProject.Path & "\学生成绩表.xls")
xlBook.Application.WindowState = xlMaximized
xlBook.Application.Sheets(1).Select
xlBook.Application.Cells(2, 2).Value = "乡村小学"
xlBook.Application.Cells(2, 5).Value = DLast("日期", "成绩表")
xlBook.Application.Cells(3, 2).Value = Me.班级.Value
xlBook.Application.Cells(3, 5).Value = DLast("科目", "成绩表")
For i = 1 To Me.成绩窗体.Form.RecordsetClone.RecordCount
Me.成绩窗体.Form.SelTop = i
xlBook.Application.Cells(i + 4, 1).Value = Me.成绩窗体.Controls("学号").Value
xlBook.Application.Cells(i + 4, 2).Value = Me.成绩窗体.Controls("姓名").Value
xlBook.Application.Cells(i + 4, 3).Value = Me.成绩窗体.Controls("性别").Value
xlBook.Application.Cells(i + 4, 4).Value = Me.成绩窗体.Controls("成绩").Value
Next
xlBook.Save
Set xlApp = Nothing
Set xlBook = Nothing
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|