Good morning/Afternoon everyone,
I have the following code to export a query to Excel and so far it exports fine, it prompts the user where to save. The issue is when the user opens the .xlsx file, excel says that the file is invalid or corrupted, here is the code, can someone tell me where I went wrong.
Code:
Private Sub Command22_Click()
Dim stDocName As String
Dim vRet, vFile
stDocName = "QryPVTPreviousQuater"
vRet = UserPickFile()
If vRet <> "" Then
If InStr(vRet, ".xlsx") = 0 Then vRet = vRet & ".xlsx"
vFile = vRet
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, stDocName, vFile
End If
End Sub
Thanks in advance.