makasih pakdhe Frans, dicoba dulu
mbokdhe siti, kumaafkan dirimu dengan segala hormat ;-)


====mod note===========================================
he he bocah wis tekan mancanegara kok ora maleh-maleh..
=======================================================


On Thu, Oct 6, 2011 at 1:27 PM, Franciscus SOG <[email protected]> wrote:

>
> Dear Yulian,
>
> Excel bisa dan mempunyai kemampuan tersebut. Sangat kebetulan, belum lama ini 
> saya juga mengerjakan project yang memerlukan coding list file in folder.
>
> Coding memerlukan Reference : Microsoft Scripting Runtime.
> Ditambahkan melalui jendela VBE, Tools > Reference > centang Microsoft 
> Sripting Runtime.
>
> Coding list file in folder didapat dari sumber yang ada diinternet. (maap 
> lupa)
>
> Berikut cuplikan coding :
>
> Sub TestListFilesInFolder()
>     Application.ScreenUpdating = False
>     Cells.Clear
>     ' add headers
>     With Range("A1")
>         .Formula = "Folder contents:"
>         .Font.Bold = True
>         .Font.Size = 12
>     End With
>     Range("A3").Formula = "File Path:"
>     Range("B3").Formula = "File Name with extension:"
>     Range("A3:B3").Font.Bold = True
>     ListFilesInFolder ThisWorkbook.Path, True
>     ' list all files included subfolders
>     Call Add_Hyperlink
>     Application.ScreenUpdating = True
> MsgBox "Done"
> End Sub
>
> Sub ListFilesInFolder(SourceFolderName As String, IncludeSubfolders As
> Boolean)
> ' lists information about the files in SourceFolder
> ' example: ListFilesInFolder "C:\FolderName\", True
> Dim FSO As Scripting.FileSystemObject
> Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
> Dim FileItem As Scripting.File
> Dim r As Long
>     Set FSO = New Scripting.FileSystemObject
>     Set SourceFolder = FSO.GetFolder(SourceFolderName)
>     r = Range("A65536").End(xlUp).Row + 1
>     For Each FileItem In SourceFolder.Files
>         ' display file properties
>         If FileItem.Name <> ThisWorkbook.Name And FileItem.Name <> "~$" &
> ThisWorkbook.Name Then
>             Cells(r, 1).Formula = FileItem.Path
>             Cells(r, 2).Formula = FileItem.Name
>             r = r + 1 '
>         End If
>     Next FileItem
>     If IncludeSubfolders Then
>         For Each SubFolder In SourceFolder.SubFolders
>             ListFilesInFolder SubFolder.Path, True
>         Next SubFolder
>     End If
>     Columns("A:H").AutoFit
>     Set FileItem = Nothing
>     Set SourceFolder = Nothing
>     Set FSO = Nothing
>     ActiveWorkbook.Saved = True
> End Sub
>
> Sub Add_Hyperlink()
>     Dim i As Integer
>
>     For i = 4 To ActiveSheet.UsedRange.Rows.Count
>         Range("B" & i).Select
>         ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Range("A" &
> i).Value, TextToDisplay:=Range("B" & i).Value
>     Next
> End Sub
>
> File terlampir sudah menambahan Reference Microsoft Scripting Runtime.
>
> CMIIW
>
> Blessings,
>
> Fran'z

Kirim email ke