How to export multilanguage Unicode records to multiple text files

world33

Registered User.
Local time
Today, 12:01
Joined
Oct 24, 2006
Messages
21
Hi,

I cannot find a solution to these two issues.


1) My Table "UNIVERSITIESOtherName" is made of University names in non-english characters:

ID UniversityOther
87 "Երևանի ""Հայբուսակ"" Համալասարան"
190 جامعة الخليج العربي
191 الجامعة الخليجیة
192 جامعة البحرين
237 Белорусский государственный экономический университет

When I export them to multiple text files with the script below (Source: Larry Larson) I get ?????????? characters instead of the original ones.
I guess I have to somehow tell the vba script to set the character to Unicode UTF-8 and/or to use a previously saved Export Specification Schema.

Here the Function code I am using slightly adapted from Larry's one


Code:
Function Save_to_file()
Dim rst        As DAO.Recordset
Dim x          As String
  
    Set rst = CurrentDb.OpenRecordset("SELECT * FROM UNIVERSITIESOtherName")

    Do Until rst.EOF
        x = FreeFile
        Open "C:\temp\" & rst!ID & ".txt" For Append As x
        Print #x, rst!UniversityOther
        Close #x
        rst.MoveNext
    Loop
    
    rst.Close
    Set rst = Nothing

Save_to_file_Exit:
    Exit Function

End Function

The question is what is the simpliest way to set the above VBA script export function to unicode UTF-8 characters or make it use a pre-saved Export Specification Schema?

2) The second minor problem is that whenever i run the above Export Function module, content is appended to the previous one instead of being replaced
So I get ID.txt files containing several lines of question marks:

???????????
???????????
???????????

How can I modify the above script so that it replaces the existing content instead of appending to it?

Thank you very much for your time and suggestions.

FF
 
use the docmd.transferText command to export your table/query
you can set the characters code page to be used. I use 1255 to export Hebrew
 
use the docmd.transferText command to export your table/query
you can set the characters code page to be used. I use 1255 to export Hebrew

Thanks. Does that allow to export to multiple files? is there an example of code to see? Does that automatically replace the existing text as per point 2)
Cheers!
 

Users who are viewing this thread

Back
Top Bottom