khawarameer
Board Regular
- Joined
- Jun 2, 2009
- Messages
- 152
I am trying to merge some excel 2003 work books in one excel 2010 workbook with VBA and experiencing following error
"Error 1004 method open of object workbooks failed"
Following code is used.
Sub GetSheets()
Path = "C:\Users\bal-admin\Desktop\Transfer Register\"
Dim number As Integer
number = 1
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
ActiveSheet.Name = number
Sheet.Copy After:=ThisWorkbook.Sheets(1)
number = number + 1
Next Sheet
Workbooks(Filename).Close savechanges:=False
Filename = Dir()
Loop
End Sub
Any solution please
"Error 1004 method open of object workbooks failed"
Following code is used.
Sub GetSheets()
Path = "C:\Users\bal-admin\Desktop\Transfer Register\"
Dim number As Integer
number = 1
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
ActiveSheet.Name = number
Sheet.Copy After:=ThisWorkbook.Sheets(1)
number = number + 1
Next Sheet
Workbooks(Filename).Close savechanges:=False
Filename = Dir()
Loop
End Sub
Any solution please