DoCmd.TransferText acExportDelim, , "Book", "C:\txtfiles\April.csv", True
1. You asked to export a .csv file NOT a .doc file.
2. Did you look at the reference Galzxiom provided?
DoCmd.TransferText acExportDelim, , "Book", "C:\txtfiles\April.csv", True
1. You asked to export a .csv file NOT a .doc file.
2. Did you look at the reference Galzxiom provided?
Yes, I simply copied it and changed the table name. No file was transfered.
In the meanwhile I have found the following code and now it works
Dim trz As Integer
Dim strCSV As String
For trz = 1 To 511
Close #trz
Next trz
trz = FreeFile
Open "C:\Users\MyName\Documents\Book.csv" For Output Access Write As #trz
With CurrentDb.OpenRecordset("Book ")
Dim x As Integer
For x = 0 To .Fields.Count - 1
strCSV = strCSV & strColumnDelimiter & .Fields(x).Name & "; "
Next x
Print #trz, Mid(strCSV, Len(strColumnDelimiter) + 1)
Do Until .EOF
strCSV = ""
For x = 0 To .Fields.Count - 1
strCSV = strCSV & strColumnDelimiter & Nz(.Fields(x), "<NULL>") & "; "
Next x
Print #trz, Mid(strCSV, Len(strColumnDelimiter) + 1)
.MoveNext
Loop
End With
Close #trz
You said the table name was "Book". Why did you change it? I see you also changed the path. Did the path you were trying to write to with the TransferText method exist?
I guess two dozen lines of code trumps one. Glad you got it working. The TransferText works great assuming your syntax is correct.
If your export will need an export spec, you need to create the export spec by manually exporting the file once through the export wizard. On the last screen of the export, press the "Advanced" button, change any parameters that need changing and choose the save option. Once you have named and saved the export spec, you can reference it in VBA or macros using the TransferText method.
Thanks but it didn´t work with that even if I manualy export the table and save a export specification. I used a modified version of the Monoceros code and it worked greate
Is there a bug in Access? It seems many people are complaining about this.
The transfer text does not work as I get error 3441. Even if I create a transfer spec, the message then becomes Transfer Spec not found.
The data is pure text with no funny characters except ().
MyPathFileName is on another PC.