- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
        
|
¦^´_ 2# mhl9mhl9
11 ¦]¬° filesearch ¦bexcel2007¤£¦A¥i¥Î,©Ò¥H¥»¤å¥ó¤£¯à¦b2007excel¨Ï¥Î
¥i¥H¥´¶}¥»¤å¥ó,¦ý"¤å¥ó¦Cªí"¥¢®Ä.
12 ¦pªG¤£¥Î filesearch,¦Ó§ï¥ÎDir(),excel2007´N¥i¥H¥Î¤F.§Ú¸Õ¹LDir(),¦ý©â¨ú¦h¼h¤l¸ê®Æ§¨
¤å¥ó¤£²z·Q,¥»½èÁÙ¬O¾Ç±o¤£°÷.¤@ª¾¥b¸Ñ§a.
2007 ¥i¸Õ¸Õ¬Ý CreateObject("Scripting.FileSystemObject")- Option Explicit
- Dim Fs As Object, Sh As Worksheet, d As Object
- Sub iMain_Ex()
- Dim xlFileDialog As FileDialog
- Set xlFileDialog = Application.FileDialog(msoFileDialogFolderPicker) '¶}±Ò¸ê®Æ§¨ªº¹ï¸Ü®Ø
- If xlFileDialog.Show = True Then '¹ï¸Ü®Ø: ¦³«ö¤U½T©w
- Application.ScreenUpdating = False
- Set Sh = Sheet1
- Set Fs = CreateObject("Scripting.FileSystemObject") '¨t²ÎÀɮת«¥ó: ´£¨Ñ¹ï¹q¸£Àɮרt²Îªº¦s¨ú
- Set d = CreateObject("Scripting.dictionary") '¦r¨åª«¥ó
- With Sh.UsedRange
- .Clear
- .Range("a1").Resize(, 7) = Array("¸ô®|", "¤å¥ó¦W", "°ÆÀɦW", "¤å¥óªø«×", "«ØÀɤé´Á", "¦sÀɤé´Á", "µù¸Ñ")
- .Range("A1:F1").Font.Bold = True
- .Range("A1:F1").HorizontalAlignment = xlCenter
-
- ¸ê®Æ§¨_°Æµ{¦¡ xlFileDialog.SelectedItems(1)
-
- .Columns("D:D").NumberFormatLocal = "#,### ""KB"""
- .Columns("E:F").NumberFormatLocal = "yyyy-mm-dd"
- End With
- Application.ScreenUpdating = True
- End If
- End Sub
- Private Sub ¸ê®Æ§¨_°Æµ{¦¡(¸ê®Æ§¨ As String)
- Dim f As Object
- For Each f In Fs.GetFolder(¸ê®Æ§¨).Files 'Files(ª«¥ó):Àɮ׶°¦X
- With Sh.[A1].End(xlDown).End(xlDown).End(xlUp).Offset(1)
-
- Àɮת«¥ó_°Æµ{¦¡ f, .Cells
-
- ' .Range("a1") = f.ParentFolder
- ' .Range("b1") = f.Name
- ' .Hyperlinks.Add Anchor:=.Range("b1"), Address:=f
- ' .Range("c1") = Fs.GetExtensionName(f) ''Mid(F.Name, InStr(F.Name, ".") + 1)
- ' .Range("d1") = f.Size / 1024
- ' .Range("e1") = f.DateCreated
- ' .Range("F1") = f.DateLastAccessed
-
- ¦r¨åª«¥ó_°Æµ{¦¡ f, .Range("b1")
- ' If d.Exists(F.Name) Then
- ' Set d(F.Name) = Union(d(F.Name), .Range("b1"))
- ' d(F.Name).Interior.ColorIndex = 40
- ' Else
- ' Set d(F.Name) = .Range("b1")
- 'End If
-
- End With
- Next
- '********************************************
- '*** ¦p¸ê®Æ§¨¤U¦³¤l¸ê®Æ§¨ ¦A©I¥s³o°Æ.µ{¦¡ ***
- '©I¥s µ{¦¡¥»¨ªº°j°é ***
- '********************************************
- For Each f In Fs.GetFolder(¸ê®Æ§¨).SubFolders 'SubFolders(ª«¥ó):¸ê®Æ§¨¶°¦X
- ¸ê®Æ§¨_°Æµ{¦¡ f & ""
- Next
- End Sub
- Private Sub Àɮת«¥ó_°Æµ{¦¡(f As Object, Rng As Range)
- With Rng
- .Range("a1") = f.ParentFolder '¶Ç¦^«ü©wÀɮשθê®Æ§¨ªº¤÷¸ê®Æ§¨ª«¥ó¡C
- .Range("b1") = f.Name
- .Hyperlinks.Add Anchor:=.Range("b1"), Address:=f
- .Range("c1") = Fs.GetExtensionName(f) '¶Ç¦^Àɮתº°ÆÀɦW
- .Range("d1") = f.Size / 1024
- .Range("e1") = f.DateCreated 'Àɮשθê®Æ§¨ªº«Ø¥ß¤é´Á©M®É¶¡
- .Range("F1") = f.DateLastAccessed 'Àɮ׳̫á¤@¦¸¦s¨ú«ü©wÀɮשθê®Æ§¨ªº¤é´Á©M®É¶¡
- End With
- End Sub
- Private Sub ¦r¨åª«¥ó_°Æµ{¦¡(f As Object, Rng As Range)
- If d.Exists(f.Name) Then
- Set d(f.Name) = Union(d(f.Name), Rng)
- d(f.Name).Interior.ColorIndex = 40
- Else
- Set d(f.Name) = Rng
- End If
- End Sub
½Æ»s¥N½X |
|