我對MS Access非常陌生。目標是從MS Access DB導出多個PDF文件。目前我可以通過以下代碼導出多個Excel文件。但是我想通過表格(顏色,字體等)中的少量格式更改將其導出爲PDF,並向PDF添加頁眉&頁腳註釋。從MS Access輸出格式化的PDF
Private Sub Command4_Click()
Dim rsGroup As DAO.Recordset
Dim ColumnName As String
Dim myPath As String
myPath = "E:\TestExport\"
Set rsGroup = CurrentDb.OpenRecordset("SELECT DISTINCT TableName.Column FROM TableName", dbOpenDynaset)
Do While Not rsGroup.EOF
ColumnName = rsGroup!Column
Dim rsExportSQL As String
rsExportSQL = "SELECT * FROM TableName WHERE TableName.Column='" & ColumnName & "'"
Dim rsExport As DAO.QueryDef
Set rsExport = CurrentDb.CreateQueryDef("myExportQueryDef", rsExportSQL)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "myExportQueryDef", myPath & RegionName & ".xls", True
CurrentDb.QueryDefs.Delete rsExport.Name
rsGroup.MoveNext
Loop
End Sub
感謝
您好,我會建議創建一個基於你那個查詢微調的細節和格式的報告。報告完成後,只需爲其他查詢創建一個模板,然後將vba導出爲pdf。 – Lybren