3

I tried many proper unicodes for letter schwa "ə" and without dot "ı" in the VBA editor. None of them display these letters correctly.
Tried to change font shrifts but it gives an error with Russian letters.
I need both of them displayed on editor as path and there is no way to change the folder path.

I tried character wide in VBA of u+01DD, u+0259 like &H259,1DD but the result is question mark or different character.
u+0131 gives an exact i with dot.

How to display these characters in VBA?

FolderName = "C...ə(?)lsheth/folders/"
FileName =Dir(FolderName & "*.xls*")
Do While FileName <> ""
    Debug.Print FileName
    FileName = Dir()
Loop

gives an error 52, Bad name or number

I think there are many versions of schwa latin letter, and I need to try all of them as I think the solution must be one of them.
How to convert them to use in chrW() for VBA?

From unicode page:
0259 ə Latin Small Letter Schwa
• mid-central unrounded vowel
• uppercase is 018F Ə
• variant uppercase form 018E Ǝ is associated with 01DD ǝ
→ 01DD ǝ latin small letter turned e
→ 04D9 ә cyrillic small letter schwa
↑ 018F Ə latin capital letter schwa

2 Answers 2

3

As already mentioned by @Toddleson, the Visual Basic Editor doesn't support Unicode characters. And the Dir function doesn't support it either. However, the FileSystemObject object does support it.

Here's an example that uses the ChrW function to return the desired unicode character, and then uses the FileSystembObject object to loop through each file within the specified folder, filter for .xls files, opens the file, and then saves and closes it.

Sub test()

    Dim folderName As String
    folderName = "C:\Users\Domenic\Desktop\D" & ChrW(&H259) & "nmark\" 'change the path accordingly

    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    Dim folder As Object
    Set folder = fso.getfolder(folderName)
    
    Dim file As Object
    Dim wb As Workbook
    For Each file In folder.Files
        If InStr(1, file.Name, ".xls", vbTextCompare) > 0 Then
            Set wb = Workbooks.Open(file.Path)
            'etc
            '
            '
            With wb
                .Save
                .Close
            End With
        End If
    Next file
    
    Set file = Nothing
    Set folder = Nothing
    Set fso = Nothing

End Sub
Sign up to request clarification or add additional context in comments.

11 Comments

the same bad name result.
Maybe I need to try with shell command
Prior to posting my code, I made sure that the folder name contained the Unicode character "ə", and then I made sure that the file name of a workbook within the folder also contained a Unicode character. Then I ran the code, and it ran successfully. Which line is giving you that error?
fso.getfolder(Foldernme) -> '76' path not found
So in fact you're getting a "path not found", not a "bad file name". So you'll need to make sure that your path is correct, and of course you'll need to make sure that any Unicode characters are specified correctly using the ChrW function.
|
2

ChrW(399) = Ə

ChrW(305) = ı

These will not be displayed in VBE but when you assign the value into a cell, Excel will display these characters.

Alternatives:

ChrW(601) = ə

ChrW(618) = ɪ (it looks like the dotless i when printed in Calibri in Excel)

5 Comments

Thanks, I will try them. I also learnt that with DIR function I can take any path name and use it with asterisk or question mark, and it will give the exact path. I will go on with solutions. Thanks
I am not displaying them, but using as path name to get files from folder
@xlmaster If you know exactly which symbols are in the file names then you can use ChrW when creating the filepath. But it may be difficult to get exactly the right characters. It will probably be easier to use wildcards like ? and * with Dir or to use the Like operator and compare all file names to a pattern to get a match.
Sorry but with both chr wides inside string(these characters are pathnames) and with dir() it gives same error"52". Bad character name. I even used fileSystemObject but seems cannot bypass this unicode issue
where have you taken the ChrW(601) , I need to convert other encodings of Latin Schwa small letters like ; 0259, 018F,01DD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.