I am required to export data to excel with pivot and chart. Does anyone know the best practice to do so? Here is my code in Access:
Private Sub cmdExport_Click()
Dim strFile As String
Dim objXL As Object
Dim objWB As Object
strFile = CurrentProject.Path & "\Diversity File.xlsx"
If Len(Dir(strFile)) > 0 Then
Kill strFile
End If
DoCmd.TransferSpreadsheet acExport, 10, _
"Diversity with Race Combination", CurrentProject.Path & "\Diversity File.xlsx", True
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
Set objWB = objXL.Workbooks.Open(strFile)
objXL.UserControl = True
Set objXL = Nothing
strFile = CurrentProject.Path & "\Diversity File.xlsx"
MsgBox "Data export completed", vbInformation, "Completed"
End Sub
Private Sub cmdExport_Click()
Dim strFile As String
Dim objXL As Object
Dim objWB As Object
strFile = CurrentProject.Path & "\Diversity File.xlsx"
If Len(Dir(strFile)) > 0 Then
Kill strFile
End If
DoCmd.TransferSpreadsheet acExport, 10, _
"Diversity with Race Combination", CurrentProject.Path & "\Diversity File.xlsx", True
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
Set objWB = objXL.Workbooks.Open(strFile)
objXL.UserControl = True
Set objXL = Nothing
strFile = CurrentProject.Path & "\Diversity File.xlsx"
MsgBox "Data export completed", vbInformation, "Completed"
End Sub