ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[Âà¶K] ÀÉ®×¾Þ§@½d¨Ò (Dir / Filesystem Object)

[Âà¶K] ÀÉ®×¾Þ§@½d¨Ò (Dir / Filesystem Object)

Dir ¨ç¼Æ - °ò¥»ªºÀÉ®×/¸ê®Æ§¨Åª¨ú¤è¦¡
Sub ¦C¥XÀÉ®×()
path1 = "C:\Temp\*.*"
file1 = Dir(path1): r = 1
Do While file1 <> ""
¡@Cells(r, 1) = file1
¡@r = r + 1
¡@file1 = Dir '¨ú±o¤U¤@­ÓÀɦW
Loop
End Sub


--------------------------------------------------------------------------------
Dir °ò¥»À³¥Î½d¨Ò
¹ï¤@­Ó¤w³Q¨ä¥L¹q¸£(«D¥»¾÷)¥H¸ê·½¦@¨É¤è¦¡¶}±ÒªºxlsÀÉ¡A¦³¨S¦³¤°»ò¤èªk¨Ó°»´ú©Î´y­z¥¦ªºÄݩʩΪ¬ºA¡A¥Hªí¥Ü¥¦¬O¤@­Ó¡u¥Ø«e¤w³Q¶}±Ò¨Ï¥Î¤¤¡vªºÀÉ®×??

¥H¤Uªº¥¨¶°·|§â¥»¾÷©M«ü©w¥Ø¿ý¤U¨Ï¥Î¤¤ªºxlsÀɦC¥X¡C

Sub CheckFile()
Application.ScreenUpdating = False
Range("A1") = "¥»¾÷¤w¶}±ÒÀÉ®×"
For Each book In Workbooks
¡@GoSub 1: Cells(r, 1) = book.FullName
Next
mypath = "C:\": GoSub 1
myfile = Dir(mypath & "*.xls")
Cells(r, 1) = "¥L¤H¨Ï¥Î¤¤ÀÉ®×"
Do While myfile <> "" ' °õ¦æ°j°é
¡@GoSub 1: myfilename = mypath & myfile
¡@Workbooks.Open myfilename
¡@If ActiveWorkbook.ReadOnly Then Cells(r, 1) = myfilename
¡@Workbooks(myfile).Close
¡@myfile = Dir ' ´M§ä¤U¤@­ÓÀÉ®×
Loop: Exit Sub
1 r = Application.WorksheetFunction.CountA(Columns(1)) + 1: Return
End Sub

µù¡G¸ê®Æ§¨¤À¨É¼Ò¦¡À³³]©w¬°¡u§¹¾ã¡v¡A§_«h°»´ú¤£¨ì¡C


--------------------------------------------------------------------------------
Dir ¶i¶¥À³¥Î½d¨Ò
¦C¥X«ü©w¥Ø¿ý¤§¤U©Ò¦³ªº¤l¸ê®Æ§¨¤º®e¡C

Sub list_and_link1()
Dim ary() As String, rw As Long
rw = 1: i = 0
path1 = "C:\myArticle\"
file1 = Dir(path1 & "*.*", vbDirectory) '¥u³B²z¸ê®Æ§¨
Do While file1 <> ""
¡@If file1 <> "." And file1 <> ".." And _
¡@¡@ GetAttr(path1 & file1) = vbDirectory Then
¡@¡@ i = i + 1
¡@¡@ ReDim Preserve ary(i)
¡@¡@ ary(i) = file1
¡@End If
¡@file1 = Dir
Loop
For i = 1 To UBound(ary)
¡@ Cells(rw, 1) = ary(i)
¡@ rw = rw + 1
¡@ GetSubs path1 & ary(i) & "\", rw, 1
Next i
file1 = Dir(path1 & "*.*")
Do While file1 <> ""
¡@'¦¹¨Ò¥u¦C¥XÀɦW, §A¥i¼g¤W­n°µªº°Ê§@
¡@Cells(rw, 1) = file1
¡@rw = rw + 1
¡@file1 = Dir
Loop
End Sub

Sub GetSubs(sPath As String, rw As Long, ilevel As Long)
Dim ary1() As String
ReDim ary1(1)
sName = Dir(sPath, vbDirectory)
Do While sName <> ""
¡@If sName <> "." And sName <> ".." And _
¡@¡@ GetAttr(sPath & sName) = vbDirectory Then
¡@¡@ ary1(UBound(ary1)) = sName
¡@¡@ ReDim Preserve ary1(UBound(ary1) + 1)
¡@End If
¡@sName = Dir
Loop
For i = 1 To UBound(ary1) - 1
¡@ Cells(rw, ilevel + 1) = ary1(i)
¡@ rw = rw + 1
¡@ GetSubs sPath & ary1(i) & "\", rw, ilevel + 1
Next i
sName = Dir(sPath & "*.*")
Do While sName <> ""
¡@Cells(rw, ilevel + 1) = sName
¡@rw = rw + 1
¡@sName = Dir
Loop
End Sub

¦¹¨Ò°Ñ¦Ò chijanzen's post


¦VªO¥DÀËÁ|    203.79.168.37 (?)  

--------------------------------------------------------------------------------
BEFORE ASKING, YOU SHOULD RTFH, RTFM, STFW...



leonchou
½×¾ÂºûÅ@¸s

Â÷½u

¤å³¹: 1214


     ÀÉ®×¾Þ§@½d¨Ò - FileSystem ª«¥óÀ³¥Î
&laquo; ¦^ÂФ峹 #1 ©ó: 2005-09-03, 21:32:06 &raquo;      

--------------------------------------------------------------------------------

³á¡I¤Ó¦n¤F¡K¡K§Ú¥¿¶·­n³oªF¦è¡AÁÙ¨S¦³ªÅ¥h¬ã¨s¡K¡K­è¦n¥i¥H¨Ó¾Ç²ß¡I¡I¡I
ªì¾ÇVBA¥E¨ìtwbts

TOP

°w¹ï Sub ¦C¥XÀÉ®×() ³o¬q, ¥u­n¤p§ï¤@¤U, ´N¥i¥H±N¸ê®Æ§¨¤ºªºÀɮ׳v¤@¶×¤J, ¤£¥Î¦A³vÀÉ°õ¦æ,¯u¬O¦n¥Î
Homeman

TOP

¦^´_ 1# Hsieh


    ª©¥D±z¦n,
      §Ú¥ÎdirŪ¨ú¥Ø¿ý,¹J¨ìÀɮצWºÙ¦³Â²Åé¦r·|Åܦ¨?¸¹,½Ð°Ý³o­Ó°ÝÃD¦³¸Ñ¶Ü?

TOP

¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 5# Hsieh


    ÁÂÁª©¥D.

TOP

¦^´_ 1# Hsieh


ÁÂÁª©¥D´£¨Ñ¡A¬O§_¯à½Ð±Ð¤@­Ó°ÝÃD©O¡H
¦pªG¥ÎÃöÁä¦r·j´Mªº¸Ü¡ADIR»yªk¦p¦ó·j´M¨ì¡C°²³]¥H¤U¸ê®Æ§¨¦p¦ó·j´M¨ìAAA(5678)¡G
¸ê®Æ§¨½d¨Ò¡GAAA(1234)   AAA(5678)  AAA(8910)

TOP

        ÀR«ä¦Û¦b : ¥Í®ð¡A´N¬O®³§O¤Hªº¹L¿ù¨ÓÃg»@¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD