VBA

出自ProgWiki
於 2019年7月4日 (四) 22:12 由 Player討論 | 貢獻 所做的修訂 →‎參考資料
跳至導覽 跳至搜尋

VBA(Visual Basic for Applications),參照:『維基百科~Visual_Basic_for_Applications

參考資料

FAQ

取得資料夾路徑

Function GetFolder(strPath As String) As String
    Dim fldr As FileDialog
    Dim sItem As String
    Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
    With fldr
        .Title = "Select a Folder"
        .AllowMultiSelect = False
        .InitialFileName = strPath
        If .Show <> -1 Then GoTo NextCode
        sItem = .SelectedItems(1)
    End With
NextCode:
    GetFolder = sItem
    Set fldr = Nothing
End Function