Office中国论坛/Access中国论坛

标题: 请问高手,如何才能导出ACCESS表中的子表到EXCEL呢? [打印本页]

作者: girder    时间: 2010-7-16 13:08
标题: 请问高手,如何才能导出ACCESS表中的子表到EXCEL呢?
请问高手,如何才能导出ACCESS表中的子表到EXCEL呢?
[attach]42717[/attach]

作者: panjianhui    时间: 2010-7-16 17:43
子表其实也是一个数据表啊,你可以建立一个宏导出数据到Excel,如果是有条件的导出数据,你可以建立一个窗体,设定条件查询,建立一个宏将查询结果导出到Excel,或者你可以参考一下以下代码:
Private Sub Command5_Click()
Dim rs As DAO.Recordset
Dim Filnum As Long
Dim Recnum As Long
Dim xlapp As Object

Set rs = Me.打印价签导出子窗体.Form.Recordset
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
xlapp.Workbooks.Open ("D:\购好超市\促销及价格管理\标签格式\促销标签打印格式--特价.xlsx")
Dim sheet As Object
Set sheet = xlapp.sheets("内容")
rs.MoveFirst
Recnum = 2
Do Until rs.EOF
For Filnum = 0 To rs.Fields.Count - 1
sheet.cells(Recnum, Filnum + 1) = rs.Fields(Filnum)
Next
Recnum = Recnum + 1
rs.MoveNext
Loop
Set sheet = xlapp.sheets("格式1")

sheet.cells(3, 3) = "12345678"
End Sub




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3