• 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 Excel file using VBA

Status
Not open for further replies.
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


▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !
Closed as duplicate !
 

Attachments

  • Dr3M7cW-kjk ═Ω.xlsx
    9.1 KB · Views: 1
Hi !

VBA Dir function can't open weird file names as you should already
have seen yourself comparing Dir result and file name !
So just rename this kind of files.

Other way : use an ActiveX like FileSystemObject,
to see in VBA inner help or on Web …
 
Status
Not open for further replies.
Back
Top