標題:
[發問]
如何快速建立空白資料夾
[打印本頁]
作者:
luke
時間:
2012-4-5 09:54
標題:
如何快速建立空白資料夾
各位大大
小弟碰到建立資料夾問題, 我想使用兩個按鈕控制分別去建立單個或多個資料夾於桌面上(如附檔說明)
煩請先進指導
[attach]10302[/attach]
作者:
Hsieh
時間:
2012-4-5 10:40
回復
1#
luke
Sub ex()
Set fdo = CreateObject("Scripting.FileSystemObject")
fd = "C:\Documents and Settings\User\桌面\" '桌面路徑
Set a = Columns("A").Find([B1], lookat:=xlWhole)
If Not a Is Nothing Then
fs = fd & Join(Application.Transpose(Application.Transpose(a.Offset(, 1).Resize(, 3))), "-") & "-" & Format(Date, "yyyymmdd") & "\"
If fdo.folderexists(fs) = False Then MkDir fs
End If
End Sub
複製代碼
作者:
GBKEE
時間:
2012-4-5 11:04
本帖最後由 GBKEE 於 2012-4-5 13:42 編輯
回復
1#
luke
Option Explicit
Sub 建立()
Dim Rng As Range, xF As Variant, xlDesktop As String
Set Rng = Range("A7:A" & [A7].End(xlDown).Row)
Set xF = Rng.Find([b1], lookat:=xlWhole)
If xF Is Nothing Then Exit Sub
xF = Application.Transpose(Application.Transpose(Cells(xF.Row, "a").Resize(, 3).Value))
xF = Join(xF, "-") & "-" & Format(Date, "yymmdd")
xlDesktop = Get_Desktop
If Dir(xlDesktop & xF, 16) = "" Then MkDir (xlDesktop & xF) '
End Sub
Sub 全選()
Dim E As Range, xF As Variant, xlDesktop As String
xlDesktop = Get_Desktop
For Each E In Range("A7:A" & [A7].End(xlDown).Row)
xF = Application.Transpose(Application.Transpose(Cells(E.Row, "a").Resize(, 3).Value))
xF = Join(xF, "-") & "-" & Format(Date, "yymmdd")
If Dir(xlDesktop & xF, 16) = "" Then MkDir (xlDesktop & xF)
Next
End Sub
Private Function Get_Desktop() As String '函數 : 傳回所在電腦的桌面路徑
Dim ob As Object
Set ob = CreateObject("Wscript.Shell")
Get_Desktop = ob.SpecialFolders("Desktop") & "\"
End Function
複製代碼
作者:
luke
時間:
2012-4-5 20:51
回復
2#
Hsieh
建立單個資料夾測試OK
謝謝H大
作者:
luke
時間:
2012-4-5 20:53
回復
4#
luke
按鈕測試建立單/多個資料夾OK
謝謝GBKEE版大
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)