Hi All...
I have the following code, which is exporting 4 queries to 4 tabs on an excel file. The only issue I'm having with this is there is a tick mark in front of most of the cells, and some of my columns, which are numbers, are showing up as text, and excel gives an option to "covert to number" after I open it in excel. I tried using different excel formats, but some of the other formats won't give me multiple tabs. Any suggestions? I'd also like the file to open after the export if possible.
Private Sub Command1_Click()
On Error GoTo Err_bExportCurrentRecord_Click
Dim sLocation As String
Dim sFileName As String
sLocation = "I:\415757_JamesRogers\PHREF_TEST\"
sFileName = Format(Now(), "YYYYMMDD") & "AAM_RECAP_PHREF.xls"
' MsgBox sFileName 'used for testing
If Dir(sLocation & sFileName) <> "" Then
'MsgBox "The " & sLocation & sFileName & "already exists!"
Kill sLocation & sFileName
Else
'MsgBox "file does not exists"
End If
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "qryFINALAAMRECAPdistinct", sLocation & sFileName, True, "AAMRECAP"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "qryCHECKER-SORTED", sLocation & sFileName, True, "CHECKER"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "tblPHREF", sLocation & sFileName, True, "PHREF"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "qryNOTONAAMRECAP", sLocation & sFileName, True, "NOT_ON_AAM"
Beep
MsgBox "The file has been exported"
Exit_bExportCurrentRecord_Click:
Exit Sub
Err_bExportCurrentRecord_Click:
If Err = 75 Or Err = 3010 Then
Beep
MsgBox "The '" & sFileName & "'file is open." & vbCrLf & vbLf & "Please close the '" & sFileName & "' file before trying to export the data for current Position ID " & sRecordID & ".", vbCritical, "Export Error >>> " & sLocation & sFileName
Exit Sub
Else
MsgBox Err.Number, Err.Description
Resume Exit_bExportCurrentRecord_Click
End If
End Sub