返回列表 上一主題 發帖

[發問] 選擇資料夾 進而取得其名字

本帖最後由 GBKEE 於 2014-4-2 10:29 編輯

回復 2# yangjie
  1. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  2.     With fd
  3.      .AllowMultiSelect = True '
  4.      'AllowMultiSelect 屬性 True 如果允許使用者從檔案對話方塊選取多個檔案。讀/寫 Boolean
  5.     '但AllowMultiSelect 屬性對 msoFileDialogFolderPicker 不起作用
複製代碼
可用表單
  1. Option Explicit
  2. Private Sub UserForm_Initialize()
  3.     Ex
  4.     With ListBox1  '請先在表單中加入這控制項
  5.         .Font.Size = 12
  6.         .Top = 10
  7.         .Height = .ListCount * .Font.Size
  8.          DoEvents
  9.         .Left = 10
  10.         .Width = 300
  11.         .MultiSelect = fmMultiSelectMulti  '接受多重選取
  12.         Width = .Width + 20
  13.         Height = .Height + 40
  14.     End With
  15. End Sub
  16. Private Sub ListBox1_Change()
  17.     Dim s As String, i As Integer
  18.     With ListBox1
  19.         For i = 0 To .ListCount - 1
  20.             If .Selected(i) = True Then s = s & .List(i) & vbLf
  21.         Next
  22.         If s <> "" Then MsgBox s
  23.     End With
  24. End Sub
  25. Private Sub Ex()
  26.     Dim f As Object, e
  27.     Set f = CreateObject("Scripting.FileSystemObject").getfolder(CurDir).SubFolders
  28.     For Each e In f
  29.         ListBox1.AddItem e
  30.     Next
  31. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 不要小看自己,因為人有無限的可能。
返回列表 上一主題