以下是使新Excel工作预订的代码,但每次点击时,我都需要代码在同一个Excel 2007工作簿中创建新作品 SHEET Access 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
答案 0 :(得分:0)
您可以使用Transferspreadsheet:
XLFile = "C:\Docs\MyXLFile.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"MyTableOrQuery", XLFile, True, "Sheet2"
FollowHyperlink XLFile
''OR
Shell "Excel.exe " & xlfile, vbNormalFocus