How to export text files using different character set than the machine locale is?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tensto
    New Member
    • Jun 2010
    • 1

    #1

    How to export text files using different character set than the machine locale is?

    Hi,

    I am running MS Access 2003 on an XP machine. I have developed a database which have some of the tables fields in a language different than English (Eastern Europe one, Polish and others), i.e. an Unicode codepage is used as there're some specific non-English characters being used, for example in people's names.

    Here comes the tricky part -- I have written a piece of VBA code to export some tables/queries into a flat text files which are to be used later on a website and read using Perl. Everything's fine on the machine which has the Polish localization set, so the export function works great producing flat text files with the codepage ISO-8852. But -- when switching to the UK based machine, when the codepage is different, what happens is just having a 'regular' equivalent of the diacritic character in English. For example, instead of having 'ę', it exports 'e'.

    When I export the table using the Menu command (File|Export) and then choosing the Advanced Options and 'Central European (ISO)' as a Code Page, it does work for the text file.

    Now, the quesion is: how can I do it from VBA level, when all I do is (some line of the code are removed for the clarity):

    Code:
    Set qdf = CurrentDb.QueryDefs(rsQuery)
    Set rst = qdf.OpenRecordset()
    Open rsFileName For Output As #riFile
    rec = rst.GetRows(1)
    rsTmp = rec(1, 0)
    Print #riFile, rsTmp
    I know there's probably the work-around having the codepage changed somehow on the machine, but first I don't want to change it and second, I might not have had enough rights to do it as this is a corporate laptop.

    Any ideas?

    regards,
    Grzegorz
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    I think you want to use the TransferText function. Take a look at some of these threads ...







    Jim

    Comment

    • Oralloy
      Recognized Expert Contributor
      • Jun 2010
      • 988

      #3
      Another thing you might try is recording your manual export using a macro, then inspecting the resultant code and transferring the pertenent parts to your VBA code.

      Comment

      Working...