I select a list of files based on criteria using Dir and then save them in an array of strings. Then I iterate over the array and process the files.
How can I handle file names using Unicode characters?
I tried to do StrConv
, but that didn't help.
vfile = Dir(vCurrDir & vCrit, vbNormal) 'vCrit is something like *test*
Then later I will try to access the file properties as follows:
vfilename = vCurrDir & "\" & vfile Set objFSO = CreateObject("Scripting.FileSystemObject") vDateMod = objFSO.GetFile(vfilename).datelastmodified
in the last line, I get an error that the file was not found. This only happens for Unicode character file names.
Here was another post: Working with Unicode file names in VBA (using Dir, FileSystemObject, etc.) , but that does t solve the problem with
Dir '.
My example: VBA (see) c: \ my-test-file.pdf Unicode: c: \ my-test-file.pdf
(you cannot see the difference here, but if you copy the names and paste them into Notepad ++, you will see that dashes are different characters for two files, VBA converts a hyphen character to Unicode in a Windows locale dash)
Or an example from a related question: 3_PoΕish.txt (in Unicode) versus 3_Polish.txt (in VBA)
source share