hi,
Why does this code work in Excel 2000 and doesn't work in Excel 2007? VBA shows runtime error '1004' at line:
Set Wb = ExApp.Workbooks.Open(nextfile, 0)
Sub h()
directory = ThisWorkbook.Path & "\"
Dim ExApp As Excel.Application
Dim Wb As Workbook
Dim nextfile As String
Dim myfile As String
myfile = "szkod*.xls"
nextfile = VBA.Dir(directory & myfile)
Do Until Len(nextfile) = 0
Set ExApp = New Excel.Application
'Set Wb = ExApp.Workbooks.Open(.FoundFiles(x))
Set Wb = ExApp.Workbooks.Open(nextfile, 0)
Debug.Print (nextfile)
Wb.Close False
Set Wb = Nothing
Set ExApp = Nothing
nextfile = VBA.Dir()
Loop
End Sub
Why does this code work in Excel 2000 and doesn't work in Excel 2007? VBA shows runtime error '1004' at line:
Set Wb = ExApp.Workbooks.Open(nextfile, 0)
Sub h()
directory = ThisWorkbook.Path & "\"
Dim ExApp As Excel.Application
Dim Wb As Workbook
Dim nextfile As String
Dim myfile As String
myfile = "szkod*.xls"
nextfile = VBA.Dir(directory & myfile)
Do Until Len(nextfile) = 0
Set ExApp = New Excel.Application
'Set Wb = ExApp.Workbooks.Open(.FoundFiles(x))
Set Wb = ExApp.Workbooks.Open(nextfile, 0)
Debug.Print (nextfile)
Wb.Close False
Set Wb = Nothing
Set ExApp = Nothing
nextfile = VBA.Dir()
Loop
End Sub