VBA 사용자 정의 함수 - 파일 열기 대화 상자

1152 단어 VBA
Function  (Optional Title As String = " ", Optional Multi As Boolean = False, _
                    Optional FileDescription As String = " ", Optional FileType As String = "*.*") As Variant
    With Application.FileDialog(msoFileDialogOpen) '1
        .Title = Title
        .Filters.Clear
        .InitialFileName = "C:\"
        .Filters.Add FileDescription, FileType
        .AllowMultiSelect = Multi
        .InitialFileName = Environ("userprofile") & "\Desktop\"
        If .Show = -1 Then
            selectFileCount = .SelectedItems.Count
            ReDim FileArr(1 To selectFileCount)
            For i = 1 To selectFileCount
                FileArr(i) = .SelectedItems(i)
                .Execute ' , 
            Next i
              = FileArr
        Else
              = False
        End If
    End With
End Function
Sub  ()
    FileToSelect =  (Multi:=True)
    If TypeName(FileToSelect) = "Boolean" Then MsgBox " ": Exit Sub
    filecount = UBound(FileToSelect)
    For i = 1 To filecount
        MsgBox FileToSelect(i)
    Next
End Sub

좋은 웹페이지 즐겨찾기