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

[µo°Ý] Ãö©óDir ¨ú±oªº²M³æ°µ±Æ§Ç¡A·PÁÂ~

[µo°Ý] Ãö©óDir ¨ú±oªº²M³æ°µ±Æ§Ç¡A·PÁÂ~

¦U¦ì¤j¤j¡A³Ìªñ§Ú¦³¼g¤F¤@­Ó²³æªºVBA,¦p¤U:
§Ú¬O·Q­n¦b   myFile = Dir(myFolder & "*.xlsx") ®É§Y¥Ñ¦WºÙ¤p¨ì¤j¡A¶}©l°µ±µ¤U¨Óªº°Ê§@¡C
¦ý¦³ªº®É­Ô·|µo¥Í¦WºÙ¥i¯à¥Ñ¤j¨ì¤p¨Ó¶i¦æ±µ¤U¨Óªº°Ê§@¡A«Ü©_©Ç¡A¦U¦ì¤j¤jª¾¹D³o¬O¤°»ò³y¦¨ªº¶Ü?
«Ü§x´o§Ú»Ý­n¦WºÙ¬O¥Ñ¤p¨ì¤jªº¶¶§Ç°µ°Ê§@¡A·PÁ§A­Ì¡AÁÂÁÂ!~:'(

Sub file()
    Dim myFolder As String, myFile As String
    Dim i As Integer
    myFolder = "C:\New folder\"
    myFile = Dir(myFolder & "*.xlsx") '´N¬O³o¸Ì¡A·Q¦WºÙ¥Ñ¤p¨ì¤j
    i = 1
    Do While myFile <> ""
        Cells(i, 1).Value = myFile
        myFile = Dir()
        i = i + 1
    Loop
End Sub

¦^´_ 6# stillfish00
stillfish00¤j~«Ü·P°Ê¡AÁÂÁ±zªºÀ°¦£¡A§Ú©ú¤Ñ¥h¤½¥q¸Õ¤@¤U~
¤W¦¸"¸¨ÂI°ÝÃD"¤]¬O§AÀ°§Ú¸Ñªº¡A²{¦b§Ú¨C¤Ñ³£¦³¦b¥Î³á! §Ú³£¦³°O±o¡A¯uªº¯uªº~ ÁÂÁ±z ^ ^~

TOP

¦^´_ 2# ui123
  1. Sub Test()
  2.   Dim myFolder As String
  3.   Dim oFSO As Object, oFiles As Object, oFile As Object
  4.   Dim i, lCnt As Long
  5.   Dim arFiles()
  6.   
  7.   Const HIDDEN = &H2
  8.   myFolder = "C:\New folder\"
  9.   Set oFSO = CreateObject("Scripting.FileSystemObject")
  10.   Set oFiles = oFSO.getFolder(myFolder).Files
  11.   
  12.   ReDim arFiles(1 To oFiles.Count)
  13.   
  14.   '¨ú¥X©Ò¦³ÀÉ®×
  15.   i = 0
  16.   For Each oFile In oFiles
  17.     If Right(oFile.Name, 5) = ".xlsx" Then
  18.       If (oFile.Attributes And HIDDEN) = 0 Then '¤£§tÁôÂÃÀÉ
  19.         i = i + 1
  20.         arFiles(i) = oFile.Name
  21.       End If
  22.     End If
  23.   Next
  24.   If i = 0 Then MsgBox "Not Found" : Exit Sub
  25.   ReDim Preserve arFiles(1 To i)
  26.   
  27.   'array¤º±Æ§Ç
  28.   Dim temp, j
  29.   For i = 1 To UBound(arFiles)
  30.     For j = i + 1 To UBound(arFiles)
  31.       If arFiles(i) > arFiles(j) Then
  32.         temp = arFiles(i)
  33.         arFiles(i) = arFiles(j)
  34.         arFiles(j) = temp
  35.       End If
  36.     Next j
  37.   Next i
  38.   'arFiles §Y¬°±Æ§Ç«á°}¦C
  39.   
  40.   MsgBox Join(arFiles, vbCrLf)
  41. End Sub
½Æ»s¥N½X

TOP

¹ï©ó¤§«e°Ýªº°ÝÃD¡G
¦ý¦³ªº®É­Ô·|µo¥Í¦WºÙ¥i¯à¥Ñ¤j¨ì¤p¨Ó¶i¦æ±µ¤U¨Óªº°Ê§@¡A«Ü©_©Ç¡A¦U¦ì¤j¤jª¾¹D³o¬O¤°»ò³y¦¨ªº¶Ü?

§Úµo²{¦bXP®É¬OÀɮקó·sªº¤é´Á¥Ñ"·s¡÷ÂÂ"§@¬°¶¶§Ç
¦bWin8®É¬OÀɮקó·sªº¤é´Á¥Ñ"¡÷·s"§@¬°¶¶§Ç

©Ò¥H·Q½Ð°Ý¦U¦ì¤j¤j¡A¥i¥H¦bXP®É¬OÀɮקó·sªº¤é´Á¥Ñ"¡÷·s"§@¬°¶¶§Ç¶Ü???ÁÂÁÂ~

TOP

kimbal ÁÂÁ±z¡A
¦ý¦³¿ìªk¦bVBAµ{¦¡¤º°µ¨ì¶Ü?
¦]¬°·Q¦C¤@­Ó±Æ¦n¤j¤p¶¶§Çªº²M³æµ¹±µ¤U¨Óªº°j°é¨Ï¥Î¡A±z¥Îªº¤è¦¡§Ú¤F¸Ñ(¥ý¦C¥X²M³æ¦bexcel sheet ¤¤¡AµM«á¦A±Æ§Ç)¡A¦ý§ÚÁÙ¬O·Q¥ÎVBA¤¤¼g¦¨!
--------------------------------------------------------------------------------------------
§Ú¦³¬d¨ì¦bDos ¤Uªº¥Ø¿ýÅã¥Ü(DIR)¡A¥i¥H¨Ì·Ó«ü©wªº±Æ§Ç¶¶§Ç¨Ó¦C¥XÀɮסA¦p¤Uºô§}¡C¦ÓVBA©|µL§ä¨ì:
http://jax-work-archive.blogspot.tw/2009/04/dos-dir.html
·P®¦^  ^~

TOP

¦^´_ 2# ui123
    Dir ¤£¯à«ü©w±Æ¦C, ¦ý¥i¥H¦bDIR±o¥X«á±Æ§Ç
  1. Sub file()
  2.     Dim myFolder As String, myFile As String
  3.     Dim i As Integer
  4.     myFolder = "C:\temp\"
  5.     myFile = Dir(myFolder & "*.xlsx")
  6.     i = 1
  7.     Do While myFile <> ""
  8.         Cells(i, 1).Value = myFile
  9.         myFile = Dir()
  10.         i = i + 1
  11.     Loop
  12.     With ActiveSheet.Sort
  13.         .SetRange Range("A:A")
  14.         .Header = xlNo
  15.         .MatchCase = False
  16.         .Orientation = xlTopToBottom
  17.         .Apply
  18.     End With

  19. End Sub
½Æ»s¥N½X
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

ÁÙ¬O¥i¥H¦A³]¤@­Ó¦W ºÙ²M³æ¬° myFile2= myFileªº±Æ§Ç
µM«á:
  i = 1
    Do While myFile2 <> ""
        Cells(i, 1).Value = myFile2
        myFile2 = Dir()
        i = i + 1
    Loop

¤£ª¾¹D¦æ±o³q¶Ü?°Ý¤£¨ì¤H.....·P®¦

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD