會員登錄 - 用戶注冊 - 網(wǎng)站地圖 Office中國(office-cn.net),專業(yè)Office論壇
當(dāng)前位置:主頁 > 技巧 > Excel技巧 > 編程 > 正文

【Excel VBA】FileDialog 用法之 打開對話框獲得文件夾路徑

時間:2013-07-27 09:32 來源:天鳴科技 作者:Excel中國錄入員 閱讀:

FileDialog 可以根據(jù)后面的參數(shù),打開通用對話框

Dim strPath As String
Dim MyFileDialog As FileDialog
Set MyFileDialog = Application.FileDialog(msoFileDialogFolderPicker)

    If MyFileDialog.Show = -1 Then
            '使用循環(huán)顯示選取文件的路徑和名稱
        For Each vrtSelectedItem In MyFileDialog.SelectedItems
            strPath = vrtSelectedItem
        Next
    End If

MsgBox strPath

這段代碼,可以打開一個對話框,選擇文件夾,獲得選擇的文件夾的路徑

(責(zé)任編輯:admin)

頂一下
(0)
0%
踩一下
(0)
0%
發(fā)表評論
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴(yán)禁發(fā)布色情、暴力、反動的言論。
評價: