I'm having some trouble exporting Excel files to txt files through VBA. The programm goes fine and generates a bunch of txt files with the information I want. The problem is that when exported, the txt file shows the date format as American, while I want it European dd/mm/yyyy. This doesn't happen when I save the txt manually. Here it is the code I'm trying to save the txt:
tmpFile = "C:\Users\z864451\Desktop\Prueba\AIMS\AIMS_" & Filename
ActiveWorkbook.SaveAs Filename:=tmpFile _
, FileFormat:=xlText, CreateBackup:=False
I have also tried to export to csv and then convert to txt but the same problem with the date happens again.
Any idea of how can I solve this?
Thanks
I'm guessing you want to use current date.
Below should do it:
tmpFile = "C:\\Users\\z864451\\Desktop\\Prueba\\AIMS\\AIMS_" & Format(Now, “dd/MM/yyyy”)
Actually I realized the answer was just in changing the date format, when selecting the format there are two of them one is *14/03/2011 which is the one that was causing the problem, just changing it to 14/03/2001 solves the whole thing.
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.