我想創造一些VBA代碼打開一個現有的Excel工作簿,查詢轉移到一個新的工作表並保存今天的日期和時間的文件。到目前爲止,這是我的MS Access導出查詢到Excel文件模板
Private Sub cmd_planning_report_Click()
Dim ExportNumber As String
Dim ExportFileName As String
Dim ProjectPath As String
Dim FolderPath As String
Dim FilePath As String
Dim TemplatePath As String
ProjectPath = CurrentProject.Path
FolderPath = "Report_Templates"
FilePath = "Template.xlsx"
TemplatePath = ProjectPath & "\" & FolderPath & "\" & FilePath
ExportNumber = Format(Now(), "YYYYMMDD_HHMMss")
ExportFileName = "my_report_" & ExportNumber & ".xlsx"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "A1_Report", TemplatePath, True
End Sub
如查詢導出到Template.xlsx,但我想它將該文件保存爲ExportFileName其中一期工程
我不認爲這是解決方案,原來是TEMPLATEPATH Excel模板文件,我想打開,並有查詢遠銷然後另存爲ExportFileName – Naz
則必須打開Excel中使用自動化,並呼籲「另存爲 ..」。 – Gustav