It sounds like you are being misled by the fact that while VBA itself supports Unicode characters, the VBA development environment does not. The VBA editor still uses the old "code page" character encodings based on the locale setting in Windows.
Certainly FileSystemObject
et. al. do in fact support Unicode characters in file names, as illustrated by the following example. With a folder containing three plain text files
Filename: 1_English.txt
Contents: London is a city in England.
Filename: 2_French.txt
Contents: Paris is a city in France.
Filename: 3_Po?ish.txt
Contents: Warsaw is a city in Poland.
The following VBA code ...
Option Compare Database
Option Explicit
Sub scanFiles()
Dim fso As New FileSystemObject, fldr As Folder, f As File
Set fldr = fso.GetFolder("C:\__tmpso33685990files")
For Each f In fldr.Files
Debug.Print f.Path
Next
Set f = Nothing
Set fldr = Nothing
Set fso = Nothing
End Sub
... produces the following output in the Immediate window ...
C:\__tmpso33685990files1_English.txt
C:\__tmpso33685990files2_French.txt
C:\__tmpso33685990files3_Polish.txt
Note that the Debug.Print
statement converts the ?
character to l
because the VBA development environment cannot display ?
using my Windows locale (US English).
However, the following code does open all three files successfully ...
Option Compare Database
Option Explicit
Sub scanFiles()
Dim fso As New FileSystemObject, fldr As Folder, f As File, ts As TextStream
Set fldr = fso.GetFolder("C:\__tmpso33685990files")
For Each f In fldr.Files
Set ts = fso.OpenTextFile(f.Path)
Debug.Print ts.ReadAll
ts.Close
Set ts = Nothing
Next
Set f = Nothing
Set fldr = Nothing
Set fso = Nothing
End Sub
... displaying
London is a city in England.
Paris is a city in France.
Warsaw is a city in Poland.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…