Đây là cávh làm List of Content cho mỗi CD ,hoặc folders trong Hard drive . Vi dụ có Folder về các bài VBA, hay folder các bản nhac, folder về các Patch Securty Update etc....Trò chơi sắp xếp ngăn nắp
. Mỗi lần tìm dễ hơn
Có 2 cách để List ra, chỉ là Text hay muốn dùng Hyperlink để run file trực tiếp

Có 2 cách để List ra, chỉ là Text hay muốn dùng Hyperlink để run file trực tiếp
Mã:
Sub ListAllFile()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim ws As Worksheet
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets.Add
'Get the folder object associated with the directory
Set objFolder = objFSO.GetFolder("G:\Window Updated\WindowsXP\")
ws.Cells(1, 2).Value = "NAME " & objFolder.Name
ws.Cells(1, 3).Value = "SIZE " & objFolder.Name
'Loop through the Files collection
For Each objFile In objFolder.Files
ws.Cells(ws.UsedRange.Rows.Count + 1, 2).Value = objFile.Name
ws.Cells(ws.UsedRange.Rows.Count, 3).Value = objFile.Size
Next
'Clean up!
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing
End Sub
[/COĐE]
Dùng Hyperlink
[COĐE]
Sub HyperlinksToDirectory()
'
' starting at the active cell
'
Dim stDir As String
Dim stFile As String
Dim R As Range
Set R = ActiveCell
stDir = "G:\Window Updated\WindowsXP\"
stFile = Dir(stDir & "\*.*")
Do Until stFile = ""
R.Hyperlinks.Add R, stDir & "\" & stFile, , , stFile
Set R = R.Offset(1)
stFile = Dir()
Loop
R.CurrentRegion.Sort key1:=R, order1:=xlAscending, header:=xlNo
End Sub
[/COĐE]