Kaskus

Tech

lamonlamonAvatar border
TS
lamonlamon
Application.Filesearch VBA Excel 2007
Broda & sista programer

minta bantuan, gw pernah bikin program VBA excel 2003 tapi error ga mau jalan di excel 2007.

Code:
Private Sub ambilnamafile()
Set fs = Application.FileSearch
patt = InputBox("File pattern", , "xls")

Dim FolderName As String
FolderName = GetFolderName("Select a folder")
If FolderName = "" Then
MsgBox "No folder selected."
Else
MsgBox "Selected folder : " & FolderName
End If

With fs
.LookIn = FolderName
.SearchSubFolders = True
.Filename = "*." & patt
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & " " & patt & " file(s) found."
jawaban = MsgBox("Ambil fullname ?", vbYesNo)
For i = 1 To .FoundFiles.Count
'MsgBox .FoundFiles(i)
If jawaban = vbYes Then
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:=(fs.FoundFiles(i)), TextToDisplay:=(fs.FoundFiles(i))
'Cells(i, 1) = (fs.FoundFiles(i))
Else
'nama file
pj = Len(.FoundFiles(i))
For A = pj To 1 Step -1
anu = Mid(.FoundFiles(i), A, 1)
If anu = "\" Then
namaPendek = Mid(.FoundFiles(i), A + 1, pj - A)
Exit For
End If
Next A
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:=(fs.FoundFiles(i)), TextToDisplay:=namaPendek
'end of namafile
End If
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub


Adakah alternative application.filesearch di Excel 2007 ?
0
1.2K
2
GuestAvatar border
Komentar yang asik ya
Mari bergabung, dapatkan informasi dan teman baru!
Programmer Forum
Programmer Forum
KASKUS Official
20.3KThread5.1KAnggota
Urutkan
Terlama
GuestAvatar border
Komentar yang asik ya
Ikuti KASKUS di
© 2026 KASKUS, PT Darta Media Indonesia. All rights reserved.