I am trying to export an Access pivot table (a pivot table view from a query) to Excel. Whenever I did this manually, the version that appeared in Excel was just the table, not the pivot table.
So, I used the following VBA code:
Private Sub ExportPivot_Click()
DoCmd.OpenQuery "FileName ", acViewPivotTable, acEdit
DoCmd.RunCommand acCmdPivotTableExportToExcel
DoCmd.Close acQuery, "FileName "
End Sub
This works ok but I would like the file to be saved to the current directory in Excel using additional code similar to:
Dim stDocName As String
stDocName = CurrentProject.Path & "\" & "FileName"
but I have not been able to incorporate that successfully.
Could someone please advise how I can include the code to save the file and open it in Excel?
So, I used the following VBA code:
Private Sub ExportPivot_Click()
DoCmd.OpenQuery "FileName ", acViewPivotTable, acEdit
DoCmd.RunCommand acCmdPivotTableExportToExcel
DoCmd.Close acQuery, "FileName "
End Sub
This works ok but I would like the file to be saved to the current directory in Excel using additional code similar to:
Dim stDocName As String
stDocName = CurrentProject.Path & "\" & "FileName"
but I have not been able to incorporate that successfully.
Could someone please advise how I can include the code to save the file and open it in Excel?