G
Guest
I need to export a table as a text file but using the outputto or transfer
text options do not produce the file format I want. If I export the file as
Excel and then save it as text it's OK so I copied the following code to
automate the procedure but get an error 'Object variable or With block
variable not set.
Can anyone help?
Function Export()
Dim objExcel As Excel.Application
DoCmd.OutputTo acOutputTable, "MyTable", acFormatXLS, _
"c:\data\MyExcelFile.xls", False
Set objExcel = Excel.Application
objExcel.ActiveWorkbook.SaveAs Filename:= _
"C:\data\MyTextFile.txt", FileFormat:=xlText, _
CreateBackup:=False
objExcel.Quit
Set objExcel = Nothing
End Function
text options do not produce the file format I want. If I export the file as
Excel and then save it as text it's OK so I copied the following code to
automate the procedure but get an error 'Object variable or With block
variable not set.
Can anyone help?
Function Export()
Dim objExcel As Excel.Application
DoCmd.OutputTo acOutputTable, "MyTable", acFormatXLS, _
"c:\data\MyExcelFile.xls", False
Set objExcel = Excel.Application
objExcel.ActiveWorkbook.SaveAs Filename:= _
"C:\data\MyTextFile.txt", FileFormat:=xlText, _
CreateBackup:=False
objExcel.Quit
Set objExcel = Nothing
End Function