Hi
I have the following code to open each file in a directory and then call on two other macros. It works for a little but then stops and I receive the "Invalid procedure call or argument" error at the line "Filename = Dir". Is there something I have wrong?
Code the open workbooks:
Sub test()
Dim wbk As Workbook
Dim Filename As String
Dim Path As String
Path = "C:\Users\M\Desktop\Test\"
Filename = Dir(Path & "*" & ".xlsx")
'--------------------------------------------
Do While Len(Filename) > 0 'IF NEXT FILE EXISTS THEN
Set wbk = Workbooks.Open(Path & Filename)
'
Call Copy_To_Worksheets
Call Test_File_Exist_With_Dir_v1
wbk.Close True
Filename = Dir 'error is here
Loop
End Sub
Bookmarks