这是制作新 Excel 工作簿的代码,但每次单击 Access 2007 控制按钮时,我都需要该代码在同一个 Excel 2007 工作簿中创建新工作表。单击控制按钮需要打开 Access 查询并创建 Excel 工作表并打开Excel 书籍/工作表。Excel 工作簿必须是启用宏的工作簿 .xlsm 格式
' Command104ContrDonatWeekly_Click
'
'------------------------------------------------------------
Private Sub Command104ContrDonatWeekly_Click()
On Error GoTo Command104ContrDonatWeekly_Click_Err
DoCmd.OpenQuery "Contributors Who Donated in Past Week", acViewNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Contributors Who Donated in Past Week", "ExcelWorkbook(*.xlsx)", "C:\Users\Michael1\Desktop\KSN\DistributionListWeekly.xlsx", True, "", 0, acExportQualityScreen
Command104ContrDonatWeekly_Click_Exit:
Exit Sub
Command104ContrDonatWeekly_Click_Err:
MsgBox Error$
Resume Command104ContrDonatWeekly_Click_Exit
End Sub