Hello,
I am exporting individual xls files out of my access database, and during the process i would like to also save a copy as a csv file.
every time i run the code shown below it incorrectly exports the csv.
any help would be appreciated, thanks.
the code that is not working is bolded.
I am exporting individual xls files out of my access database, and during the process i would like to also save a copy as a csv file.
every time i run the code shown below it incorrectly exports the csv.
any help would be appreciated, thanks.
Private Sub Export_Report_Test_Click()
Dim sSourceFile As String
Dim sSourceQuery As String
Dim sSourceVal As String
sSourceFile = "H:\25982.00\Transmission\Conversion_Data\NY\Working\Exported_Files\"
STempFile = "H:\25982.00\Transmission\Conversion_Data\NY\Working\"
sSourceQuery = "Export_Data-qry"
sSourceVal = Forms!Export_Data_frm!Circuit_combo
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, sSourceQuery, STempFile & "Temp.xls"
Dim xlObj
Set xlObj = CreateObject("excel.application")
xlObj.workbooks.Open STempFile & "Circuit_Loader_Data_file.xls"
xlObj.activeworkbook.SaveAs sSourceFile & Me.Circuit_combo.Value & ".xls"
xlObj.workbooks.Open STempFile & "Temp.xls"
xlObj.activesheet.range("A2:Q1000").select
xlObj.selection.copy
xlObj.workbooks(Me.Circuit_combo.Value & ".xls").Activate
xlObj.activeworkbook.sheets(1).range("A3").select
xlObj.activesheet.paste
xlObj.activeworkbook.Save
xlObj.activeworkbook.SaveAs sSourceFile & Me.Circuit_combo.Value & ".csv", FileFormat = xlCSV
xlObj.activeworkbook.Close
xlObj.activeworkbook.Save
xlObj.activeworkbook.Close
xlObj.Quit
Set xlObj = Nothing
MsgBox "Your Data is exported!"
End Sub
the code that is not working is bolded.