- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
3#
發表於 2014-4-2 10:22
| 只看該作者
本帖最後由 GBKEE 於 2014-4-2 10:29 編輯
回復 2# yangjie - Set fd = Application.FileDialog(msoFileDialogFolderPicker)
- With fd
- .AllowMultiSelect = True '
- 'AllowMultiSelect 屬性 True 如果允許使用者從檔案對話方塊選取多個檔案。讀/寫 Boolean
- '但AllowMultiSelect 屬性對 msoFileDialogFolderPicker 不起作用
複製代碼 可用表單- Option Explicit
- Private Sub UserForm_Initialize()
- Ex
- With ListBox1 '請先在表單中加入這控制項
- .Font.Size = 12
- .Top = 10
- .Height = .ListCount * .Font.Size
- DoEvents
- .Left = 10
- .Width = 300
- .MultiSelect = fmMultiSelectMulti '接受多重選取
- Width = .Width + 20
- Height = .Height + 40
- End With
- End Sub
- Private Sub ListBox1_Change()
- Dim s As String, i As Integer
- With ListBox1
- For i = 0 To .ListCount - 1
- If .Selected(i) = True Then s = s & .List(i) & vbLf
- Next
- If s <> "" Then MsgBox s
- End With
- End Sub
- Private Sub Ex()
- Dim f As Object, e
- Set f = CreateObject("Scripting.FileSystemObject").getfolder(CurDir).SubFolders
- For Each e In f
- ListBox1.AddItem e
- Next
- End Sub
複製代碼 |
|