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

[µo°Ý] Application.FileSearch µLªk¨Ï¥Î

[µo°Ý] Application.FileSearch µLªk¨Ï¥Î

¦U¦ì¥ý¶i¦¹²Î­pªí«Y¥Hoffice 2003ª©»s§@¡A¦ý¦]¤½¥q§ó·s¬°office 2010ª©¡A¨ä¤¤­ì¦³³¡¤À¥\¯àµLªk¨Ï¥Î
¥Ø«eª¾¹D«Y¦]Application.FileSearchµLªk¦A¨Ï¥Î¡A¸g¤Wºô¬d¸ß¥i¨Ï¥Îdir¥N´À¡A¦ý¦Û¤v¥\¤O¤£¨¬¤´µLªk¥¿±`°õ¦æ¡A
ÁٽЦU¦ì¥ý¶i¦h¥[«ü¾É¡A«Ü©êºp³o¬O¤@­ÓwordÀɦý¬Û«Hµ{¦¡½X¬O¬Û³qªº¡A­Y¦³µo¿ù½Ð¨£½Ì

123.rar (16.71 KB)

TOP

³o¤G«h§Ú¤]³£¦³·j´M¨ì¡A¦ý¬O¦Û¤v«o®M¥Î¤£¨Ó¡A©Ò¥H¤~¦A½Ð±Ð¸Ñ¨M¤è¦¡¡A¤£³Ó·P¿E

TOP

¦^´_ 3# h60327
¼g¤F¤@­Óª«¥óÃþ§O¼Ò²Õ¡A¥u¹ê²{§A¦³¥Î¨ìªº³¡¤ÀFileSearch¥\¯à
¨Ï¥Î¤èªk:
1. Project ¤¤´¡¤J¤@­Óª«¥óÃþ§O¼Ò²Õ¡Aª«¥óÃþ§O¼Ò²ÕName§ï¬°clsFileSearch¡A¶K¤W¥H¤Uµ{¦¡½X
  1. Private msLookIn As String
  2. Private msFileName As String
  3. Private mbSearchSubFolders As Boolean
  4. Private mcolFoundFiles As Collection

  5. Private Sub Class_Initialize()
  6.   Set mcolFoundFiles = New Collection
  7. End Sub

  8. Public Property Get LookIn() As String
  9.   LookIn = msLookIn
  10. End Property
  11. Public Property Let LookIn(ByVal sLookIn As String)
  12.   msLookIn = sLookIn
  13. End Property

  14. Public Property Get FileName() As String
  15.   FileName = msFileName
  16. End Property
  17. Public Property Let FileName(ByVal sFileName As String)
  18.   msFileName = sFileName
  19. End Property

  20. Public Property Get SearchSubFolders() As Boolean
  21.   SearchSubFolders = mbSearchSubFolders
  22. End Property
  23. Public Property Let SearchSubFolders(ByVal bSearchSubFolders As Boolean)
  24.   mbSearchSubFolders = bSearchSubFolders
  25. End Property

  26. Public Property Get FoundFiles() As Collection
  27.   Set FoundFiles = mcolFoundFiles
  28. End Property

  29. Public Function Execute() As Long
  30.   Dim oFSO As Object, oFolder As Object
  31.   Dim oFile
  32.   
  33.   Set oFSO = CreateObject("Scripting.FileSystemObject")
  34.   Set mcolFoundFiles = New Collection '²MªÅ
  35.   
  36.   If oFSO.FolderExists(msLookIn) Then
  37.     Set oFolder = oFSO.GetFolder(msLookIn)
  38.     For Each oFile In oFolder.Files
  39.       If oFile.Name Like msFileName Then mcolFoundFiles.Add oFile.Path
  40.     Next
  41.    
  42.     If mbSearchSubFolders Then FindSubFolder oFolder.subfolders
  43.   End If
  44.   
  45.   Execute = mcolFoundFiles.Count
  46. End Function

  47. Private Sub FindSubFolder(ByRef oSub As Object)
  48.   Dim x, oFile
  49.   For Each x In oSub
  50.     For Each oFile In x.Files
  51.       If oFile.Name Like msFileName Then mcolFoundFiles.Add oFile.Path
  52.     Next
  53.    
  54.     FindSubFolder x.subfolders
  55.   Next  
  56. End Sub
½Æ»s¥N½X
2. µM«á§â§AªºCommandButton1_Click()¤¤ªº
    Set fs1 = Application.FileSearch
    §ï¦¨
    Set fs1 = New clsFileSearch
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 4# stillfish00
·PÁÂstillfish00«e½úªºÀ°¦£¡A²×©ó¥i¥H¨Ï¥Î¡A´î¤Ö«Ü¦hªº²Î­p®É¶¡ ¡C

TOP

        ÀR«ä¦Û¦b : ÁÀ¨¥¹³¤@¦·²±¶}ªºÂAªá¡A¥~ªí¬üÄR¡A¥Í©Rµu¼È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD