Поиск

Диалог открытия файла(ов) Excel

Dim thisB As Workbook
Set thisB = ActiveWorkbook
PS = Application.PathSeparator
With Application.FileDialog(msoFileDialogFilePicker)
       .InitialFileName = thisB.Path & PS 
       .AllowMultiSelect = False
       .ButtonName = "OK"
       .Filters.Clear
       .Filters.Add Description:="Файлы Microsoft Excel", _
            Extensions:="*.xls; *.xlsx; *.xlsm"
       If .Show = 0 Then
            Exit Sub
       End If
       myPath = .SelectedItems(1)
End With

Set sB = Nothing
For Each dB In Application.Workbooks
    If dB.FullName = myPath Then
        Set sB = dB
        Exit For
    End If
Next
If sB Is Nothing Then
    Set sB = Workbooks.Open(myPath, False)
End If