Hello,
I am looping through workbooks, whenever file name has "CAP CPU" on its file name it opens the Workbook, using the below code:
Sub LoopingFiles_Update()
Dim StrFile As String
StrFile = Dir("c:\testfolder\*CAP CPU*")
Do While Len(StrFile) > 0
Debug.Print StrFile
StrFile = Dir
Application.Workbooks.Open (StrFile)
Loop
End Sub
Here is the error I am getting
Run-time error '1004':
Sorry, we couldn't find CAP CPU_New.xlsm. Is it possible it was moved, renamed or deleted?
I am using Windows 7, and the file is in the correct folder. By looping with F8 I can see StrFile gets the correct file name "CAP CPU_New.xlsm".
It is strange that it worked twice, now, it is not working anymore.
Can anyone help me please?
Thanks!!
Bookmarks