vba excel Error 76, path not found when the folder name is Persian

Samira Sarhadi 1 Reputation point
2022-11-20T07:51:56.577+00:00

Hi,

I want to open a file from my directory. when all folders name and the file name are English, everything is ok. but when I choose a folder that it's name contains Persian characters (just this two characters: "ی" and "ک") it returns Error 76: path not.
I checked the windows language and location setting on y windows, and it is ok.

thank you for your help.

Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,206 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Emi Zhang-MSFT 26,031 Reputation points Microsoft Vendor
    2022-11-21T08:01:55.55+00:00

    Hi @Samira Sarhadi ,
    Can you save as the file with the 2 characters: "ی" and "ک"?
    Did this problem only appear in Excel? How about other product? Try to save Word document and Text file.
    I suggest you open Excel- go to File- Options- Language, make sure you're using the correct language:

    262426-image.png

    Please be a bit more precise to explain your problem or you can upload a screenshot so that I can get more accurate solutions to this problem. I’m glad to help and follow up your reply.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Samira Sarhadi 1 Reputation point
    2022-11-21T09:25:48.747+00:00

    hi @Emi Zhang-MSFT ,
    thank you so much
    my language settings are correct

        Fname = Application.GetOpenFilename(MultiSelect:=True)  
          
        For K = LBound(Fname) To UBound(Fname)  
            If Right(Fname(K), 4) = ".txt" Then  
                Open Fname(K) For Input Access Read As #1  
            End If  
      
        Next K  
    

    I use this cod to open a text file
    if all folders name doesn't contain "ی" and "ک" every thing is ok.

    0 comments No comments

  3. Viorel 118.4K Reputation points
    2022-11-22T20:51:15.72+00:00

    Add a reference to "Microsoft Scripting Runtime" and try an alternative (instead of Open Fname(K)...):

    Dim fso As Scripting.FileSystemObject  
    Dim ts As Scripting.TextStream  
      
    Set fso = New Scripting.FileSystemObject  
    Set ts = fso.OpenTextFile(Fname(K), ForReading, False, TristateUseDefault)  
      
    Dim allText As String  
    allText = ts.ReadAll  
    MsgBox allText  
      
    ts.Close  
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.