I have to export data from Access multiple times a day as a CSV file. The person who had my job before me created this VBA code that exports the data in the click of a button. However, I need to modify it so that it exports as UTF-8 without BOM so that international characters will show up in the software that I import it to.
I can manually export as Text and then save it as CSV, when I go to the "Advanced..." settings I select Code Page: Unicode (UTF-8)
and this works perfectly. But as I said before, I want to change the VBA code:
Private Sub Command6_Click()
Dim sExportPath As String
Dim qry As DAO.QueryDef
With Me.List0
For i = 0 To .ListCount - 1
If .Selected(i) Then
sExportPath = Application.CurrentProject.Path & "\final_" & Left(Me.List0.Column(0, i), InStr(Me.List0.Column(0, i), " ") - 1) & ".csv"
If QueryExists("Final") Then CurrentDb.QueryDefs.Delete "Final"
Set qry = CurrentDb.CreateQueryDef("Final", "Select Salutation,Email from " & Left(Me.List0.Column(0, i), InStr(Me.List0.Column(0, i), " ") - 1))
CurrentDb.QueryDefs.Refresh
DoCmd.TransferText acExportDelim, , "Final", sExportPath, True
End If
Next i
End With
End Sub
Use the value 65001 as CodePage parameter (the last one of the TransferText method), which is represents Unicode (UTF-8).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With