- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
3#
發表於 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
複製代碼 |
|