access操作excel数据并保存预览打印并退出 |
|
www.nanhushi.com 佚名 不详 |
Dim xlApp As Excel.Application Dim xlBook As Workbook, xlSheet As Worksheet
Set xlApp = CreateObject("Excel.Application") Set xlApp = New Excel.Application xlApp.Visible = True Set xlBook = xlApp.Workbooks.Open("e:\data\database\temp.xls") Set xlSheet = xlBook.Worksheets(1)
'打开数据表 Dim TableA As Recordset, DB As Database, Wks As Workspace Dim tmpDate As String, tmpBuMen As String, tmpLeiBie As String, tmpJinE As Currency Dim X As Long, Y As Long Set Wks = Workspaces(0) Set DB = CurrentDb() Set TableA = DB.OpenRecordset("report-各材料本月领用表", dbOpenSnapshot) '打开查询 TableA.MoveFirst tmpDate = TableA!数据启用日期 tmpBuMen = TableA!部门或单位名称 tmpLeiBie = TableA!类别 tmpJinE = TableA!支出金额 xlSheet.Cells(3, 1) = "制表日期:" + tmpDate + " 月" Y = Val(tmpLeiBie) X = Val(tmpBuMen) + 8 xlSheet.Cells(X, Y) = tmpJinE Do Until TableA.EOF = True tmpBuMen = TableA!部门或单位名称 tmpLeiBie = TableA!类别 tmpJinE = TableA!支出金额 Y = Val(tmpLeiBie) X = Val(tmpBuMen) + 8 xlSheet.Cells(X, Y) = tmpJinE TableA.MoveNext Loop TableA.close xlBook.Save xlSheet.PrintPreview xlBook.close xlApp.Quit
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: 获得Excel文件的sheet名称和数量 下一篇文章: 判断表是否存在的函数 |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|