• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unable to open an Excel file using VBA

Hi,

I have written a vba code to loop through all files and do some specific work. However I am not able to open one file (Attached) through vba and hence its throwing me an error. But I can open this Excel file by double clicking on the file. May be because the file contains special character but the client is saying that if we can open the file using normal excel, why can't you do the same through macro.

I am using the below code in my workbook

'Target File Extension (must include wildcard "*")
myExtension = "*.xlsx"

'Target Path with Ending Extention
myFile = Dir(mySrcPath & myExtension)

'Loop through each Excel file in folder
Do While myFile <> ""
'Set variable equal to opened workbook
Set wb = Workbooks.Open(Filename:=mySrcPath & myFile)

Can you please help?

Thanks in advance.

Dileep
 

Attachments

  • Dr3M7cW-kjk ═Ω.xlsx
    9.1 KB · Views: 2
Did You read that link?
There are rules for filenames.
Maybe even VBA won't allow all possible variations with filenames.
Did You notice difference of those values?
 
Did You read that link?
There are rules for filenames.
Maybe even VBA won't allow all possible variations with filenames.
Did You notice difference of those values?

Yes I did, and I knew this before, it say we cannot use special characters in file names and the file that I attached is a valid file name since it doesn't contain any special characters that are mentioned in this link. Excel itself wont allow the special characters when naming a file.
 
There is at least one special character; after 'k'!
Look again! It's not "="!

If not "=", may some other character but that is not among the prohibited characters in listed in that link. Same goes with last character of the file name omega.

upload_2017-4-1_16-1-19.png
 
... anyway that character do not match!
It's much more simply to use like 'A'...'Z' & '0'..'9' than
use some 'copy&paste'-result!
 
Back
Top