如何向 Microsoft Access 报告添加按钮以将其导出为 Excel/PDF?
最佳答案
我只是结合了之前的一些答案,这是我的最终代码块,它将报告导出到 Excel,然后打开所述 Excel 文件。
Private Sub Command79_Click()
'initialize variables
Dim strReportName As String
Dim strPathUser As String
Dim strFilePath As String
'set variables
strReportName = "AlarmLetterForSF"
strPathUser = Environ$("USERPROFILE") & "\my documents\"
strFilePath = strPathUser & strReportName & Format(Date, "yyyymmdd") & ".xls"
'export to excel
DoCmd.OutputTo acOutputReport, strReportName, acFormatXLS, strFilePath
'launch excel file
Dim Shex As Object
Set Shex = CreateObject("Shell.Application")
Shex.Open (strFilePath)
End Sub
关于ms-access - 如何向 Access 报告添加按钮以将其导出到 Excel/PDF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1740990/