ms-access - 如何向 Access 报告添加按钮以将其导出到 Excel/PDF?

标签 ms-access vba report

如何向 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/

相关文章:

mysql - 数据库 : Migrate data between MS Access DB and MYSQL

database - 查找 .accde Access 可执行文件引用的数据库或文件?

c# - 添加数据源后,如何 Access ?

excel - 将 Excel 工作表范围导入到 Ms Access Table

c# - 不可调用成员 'File' 在生成报告时不能像方法一样使用

matlab - "pdfLatex has stopped working"Matlab调用时提示

sql - 在 ms access 中显示空白(null/empty)值

excel - VBA 将文件复制为不同的文件扩展名

excel - VBA 执行存储在单元格中的代码 - 有可能吗?

C# Winform - 如何通过向 ReportViewer 传递 3 个变量(即 Reportname(RDL 文件)、SQLstring 和 Connectionstring)来显示实时报告