不久前,我从网上获得了以下 VBA 代码:
Private Sub btnCreatePDF_Click()
Dim MyPath As String
Dim MyFilename As String
MyPath = "D:\reports\"
MyFilename = "KS1.pdf"
'Open report preview and auto-save it as a PDF
DoCmd.OpenReport "Rpt_KS1", acViewPreview
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, False 'Change false to true here to auto-open the saved PDF
'Close the previewed report
DoCmd.Close acReport, "Rpt_KS1"
End Sub
它用于在 MS Access 中创建单个 pdf 报告(最多包含 30 页),并且可以很好地满足我的需要。但是,我现在需要将报告分成 30 页左右,并为每一页创建一个 pdf。知道如何做到这一点吗?我在报告中有一个“用户名”,或者如果这有助于拆分它们等,可以添加一个唯一 ID。