- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 259
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-30
|
[Âà¶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¨Ó°»´ú©Î´yz¥¦ªºÄݩʩΪ¬º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¤Wn°µªº°Ê§@
¡@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 ª«¥óÀ³¥Î
« ¦^ÂФ峹 #1 ©ó: 2005-09-03, 21:32:06 »
-------------------------------------------------------------------------------- |
|