Hello!
There’s a macro for copying workbooks of one folder in one workbook. It works fine on Windows, but mistake ‘429’ appears on Mac MS Office 2011. Activex component can't create object when executing the following command:
Set fso = CreateObject("scripting.filesystemobject").getfolder(ThisWorkbook.Path)
I know that the Mac did not have the reference to the “Microsoft Scripting Runtime” so I found the following information but don’t know how to apply it:
Drop-in replacement for Scripting.Dictionary on Mac (first link in Google)
I think it can solve the problem. If anyone has experienced the same problem, I would really appreciate your advice on how to use this dictionary below in my code.
Sub Соединение_книг()
Dim fso As Object, file As Object
Dim wb As Workbook, w As Workbook, ws As Worksheet, sh As Worksheet
Application.EnableEvents = 0
Application.ScreenUpdating = 0
Set w = ThisWorkbook
For Each sh In w.Worksheets
sh.UsedRange.Offset(1).Clear
Next
Set fso = CreateObject("scripting.filesystemobject").getfolder(ThisWorkbook.Path)
On Error Resume Next
For Each file In fso.Files
If InStr(1, file.Name, w.Name) Then
Else
Set wb = Workbooks.Open(file.Path)
For Each ws In wb.Worksheets
Dim Name As String
Dim LastRow As String
Name = wb.Name
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Таблица").Range("R2:R" & LastRow).Value = Name
Set sh = w.Sheets(ws.Name)
If Not sh Is Nothing Then
ws.UsedRange.Offset(1).Copy sh.Cells(Rows.Count, 1).End(xlUp).Offset(1)
Else
ws.Copy After:=w.Sheets(w.Sheets.Count)
End If
Set sh = Nothing
Next
wb.Close 0
Set wb = Nothing
End If
Next
Set fso = Nothing
Application.ScreenUpdating = -1
Application.EnableEvents = -1
End Sub
Bookmarks