Foreign characters problem [import CSV to Query]

Akbarov

Board Regular
Joined
Jun 30, 2018
Messages
123
Hello Dear community,

I use following VBA to convert CSV to Excel . Everything works fine, but it is not showing Polish letters correct.
I need to set ISO-8859-2 as encoding. But can't figure out how
VBA Code:
    Dim xFileName As Variant
    Dim rg As Range
    Dim xAddress As String
    xFileName = Application.GetOpenFilename(, , , False, False)
    If xFileName = False Then Exit Sub
    On Error Resume Next
    Set rg = ThisWorkbook.Worksheets("DATA").Range("A24:A2000")
    On Error GoTo 0
    If rg Is Nothing Then Exit Sub
    xAddress = rg.Address
    With Sheets("DATA")
        With .QueryTables.Add("TEXT;" & xFileName, .Range(xAddress))
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 1250
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = True
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileTrailingMinusNumbers = False
        .Refresh BackgroundQuery = False
        End With
    End With
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,018
Office Version
  1. 2016
Platform
  1. Windows
Will this solve your problem?
In Control Panel, Region has to be changed to Poland: Control Panel->Region->Change System Locale->Polski
 

Akbarov

Board Regular
Joined
Jun 30, 2018
Messages
123
Thanks for reply, but this is not only for me, so i need vba solution.
 

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,018
Office Version
  1. 2016
Platform
  1. Windows
You are welcomed
 

Watch MrExcel Video

Forum statistics

Threads
1,127,662
Messages
5,626,160
Members
416,165
Latest member
baobao3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top