C
Chris Freeman
I have a function that is exporting an Excel file from the database, and
everything works fine. I want to, in the Access code, open the file and save
as a csv file. So far I can SaveAs with a csv extension, but it does not
change the format to CSV, like SaveAs from within Excel:
D = Format(Date, "mmddyy")
File = "APECS_Address_Import.csv"
Folder = "\\APECS Conversion\"
FileName = Folder & File
Set xlx = CreateObject("Excel.Application")
'hide the file saveas function from user
xlx.Visible = False
Set xlw = xlx.Workbooks.Open(FileName)
Set xl = xlw.Worksheets(1)
xl.Name = "APECS Update"
xlw.SaveAs (Filename)
xlx.DisplayAlerts = False
xlw.Close
xlx.Quit
When I track the SaveAs code via an Excel macro, I have:
ActiveWorkbook.SaveAs FileName:= _
"\\apecs conversion\APECS_Address_Import.csv", FileFormat:=xlCSV _
, CreateBackup:=False
I see that I'm not incorporating the FielFomat:=xlCSV, but can't figure out
how to incorprate it. I tiried:
xlw.SaveAs (Filename,FileFormat)
but this was a code violation.
Any suggestions?
TIA
everything works fine. I want to, in the Access code, open the file and save
as a csv file. So far I can SaveAs with a csv extension, but it does not
change the format to CSV, like SaveAs from within Excel:
D = Format(Date, "mmddyy")
File = "APECS_Address_Import.csv"
Folder = "\\APECS Conversion\"
FileName = Folder & File
Set xlx = CreateObject("Excel.Application")
'hide the file saveas function from user
xlx.Visible = False
Set xlw = xlx.Workbooks.Open(FileName)
Set xl = xlw.Worksheets(1)
xl.Name = "APECS Update"
xlw.SaveAs (Filename)
xlx.DisplayAlerts = False
xlw.Close
xlx.Quit
When I track the SaveAs code via an Excel macro, I have:
ActiveWorkbook.SaveAs FileName:= _
"\\apecs conversion\APECS_Address_Import.csv", FileFormat:=xlCSV _
, CreateBackup:=False
I see that I'm not incorporating the FielFomat:=xlCSV, but can't figure out
how to incorprate it. I tiried:
xlw.SaveAs (Filename,FileFormat)
but this was a code violation.
Any suggestions?
TIA