Eu usei o seguinte código para resolver meus problemas:
Eu criei AvivoWB = ActiveWorkbook
e usei isso no código.
Como minha expectativa, precisei alterar o directory = "c: est\"
para directory = GetFolderName() & "/"
Sub Import_Excel_sheets()
Dim directory As String
Dim fileName As String
Dim sheet As Worksheet
Set ActivoWB = ActiveWorkbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
directory = GetFolderName() & "/"
fileName = Dir(directory & "*.xl??")
Do While fileName <> ""
Workbooks.Open (directory & fileName)
For Each sheet In Workbooks(fileName).Worksheets
Workbooks(fileName).Worksheets(sheet.Name).Copy _
after:=ActivoWB.Sheets(ActivoWB.Sheets.Count)
Next sheet
Workbooks(fileName).Close
fileName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
O código da função não foi alterado e também deve ser adicionado à pasta de trabalho:
Public Function GetFolderName(Optional OpenAt As String) As String
Dim lCount As Long
GetFolderName = vbNullString
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = OpenAt
.Show
For lCount = 1 To .SelectedItems.Count
GetFolderName = .SelectedItems(lCount)
Next lCount
End With
End Function