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

[µo°Ý] FileExists ¤èªk¯à§_§ä´M¦³µL¹Ï¤ùÀɦs¦b¡H

[µo°Ý] FileExists ¤èªk¯à§_§ä´M¦³µL¹Ï¤ùÀɦs¦b¡H

¬O§_¸Ó¤èªk¤£¯à¨Ï¥Î¬P¸¹* ¦r¤¸¨Ó§ä´M²Å¦Xjpg®æ¦¡ªº¹Ï¤ùÀÉ¡H
µ{¦¡½X¦p¤U¡A½Ð«ü±Ð

Sub photoConv()
    Dim myFSO As New FileSystemObject
    Dim myPath As String
    Dim myPhoto As String
    myPath = ThisWorkbook.Path
    myPhoto = myPath & "\" & "­ì©l¬Û¤ù" & "\" & "*.jpg"
    If myFSO.FileExists(myPhoto) Then
        MsgBox "good job"
    Else
        MsgBox "not good"
    End If
End Sub

¥H¤W·|Åã¥Ü¡unot good¡v
-------------------------------------------------------------------------------
Sub photoConv()
    Dim myFSO As New FileSystemObject
    Dim myPath As String
    Dim myPhoto1 As String
    myPath = ThisWorkbook.Path      
    myPhoto1 = myPath & "\" & "­ì©l¬Û¤ù" & "\" & "1Blue hills.jpg"
    If myFSO.FileExists(myPhoto1) Then
        MsgBox "good job"
    Else
        MsgBox "not good"
    End If
End Sub

«h¥i¥HÅã¥Ü¡ugood job¡v
HELLO !!

¦^´_ 1# baconbacons


   myPhoto = dir(myPath & "\" & "­ì©l¬Û¤ù" & "\" & "*.jpg")
    If  myPhoto<>¡¨¡¨ Then msgbox ¡¨good job¡¨ else msgbox ¡¨not found photo¡¨
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 2# Hsieh
Hsieh ¤j¡G
¸Õ¹L¤F ½T¹ê¥i¦æ  ·PÁÂ
¦ý¯à§_ª¾¹D§Ú­ì¥ýªºµ{¦¡¬°¦ó¤£¥i¦æ¡H¬OFileExists ¤èªk¥»¨­ªº°ÝÃD¶Ü¡H
HELLO !!

TOP

¦^´_ 3# baconbacons
°l¥[¤@­Ó°ÝÃD½Ð±Ð
¦pªG·Q±oª¾¸Ó¸ê®Æ§¨¤¤ªºJPGÀɼƶqªº¸Ü ¸Ó¨Ï¥Î¤°»ò¤è¦¡¡H
HELLO !!

TOP

¦^´_ 3# baconbacons


    FileExists¤èªk¤£¯à¨Ï¥Î¸U¥Î¦r¤¸
Àɮ׸ô®|¥²¶·©ú½T
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 4# baconbacons
¸Õ¸Õ¬Ý   §Ú´¿¸g¼g¹L
Sub test()
    Dim FileName As Variant
    Dim xlfileName As String
    Dim FolderName As Variant
    Dim f1 As Object
    Set f1 = CreateObject("Scripting.FileSystemObject")
    Set myfiles = f1.GetFolder(ThisWorkbook.Path ).Files
    n = 0
    For Each myfile In myfiles
        If UCase(f1.getextensionname(Path:=myfile)) = "JPG" _
            Or UCase(f1.getextensionname(Path:=myfile)) = "JPEG" _
            Or UCase(f1.getextensionname(Path:=myfile)) = "GIF" _
            Or UCase(f1.getextensionname(Path:=myfile)) = "BMP" Then
            n = n + 1
        End If
    MsgBox n
    Set f1 = Nothing
End Sub

TOP

¦^´_ 6# yangjie
yangjie¤j¡G¥H¤U­pºâ¹Ï¤ù¼Æ¶qªº¼gªk¬O§Ú¥ý¦bºô¸ô¤W§ä¨ìªº¤èªk¡uFiles.Count¡v
                       ¦ý¤£ª¾¹D¬°¤°»ò¼Æ¶qµ²ªGÁ`¬O·|¦h¥X1¡A©Ò¥H§Ú¥²¶·­n¦©°£1¤~·|²Å¦X¹ê»Ú¼Æ¥Ø
                       §Ú¤]¦³½T»{¹L¨Ã¨S¦³ÁôÂÃÀÉ¡A¯à§_ª¾¹D¬°¦ó¦³³oºØ±¡ªp¡H
                       ps¡Gyangjie¤j §Aªº¤èªk½T¹ê¥i¥H ·PÁ±оÉ
                                ¥t¥~¦A½Ð±Ðyangjie¤j¡A§A¦b¨Ï¥ÎFor Each ____  In  ____ªº¼gªk
                                ¬O«ç¼Ëªº«ä¦Ò¤è¦¡¡A¦b¤°»ò±¡¹Ò¤U·|¦Ò¼{¨Ï¥Î¨ì³oºØ¤èªk
                                ³o¼gªk¬Ý§O¤H¼g³£¬O¥i¥H²z¸Ñ¡A¦ý¤£ª¾¹D«ç»ò¥Îªº¥X¨Ó
                                ³Â·Ð«ü±Ð
  ----------------------------------------------------------------------------------------------------
Sub photoConv()
    Dim myFSO As New FileSystemObject
    Dim myPath As String
    Dim myPhoto As String, countPhoto As String
    myPath = ThisWorkbook.Path      
    myPhoto = Dir(myPath & "\" & "­ì©l¬Û¤ù" & "\" & "*.jpg")
    countPhoto = myFSO.GetFolder(myPath & "\" & "­ì©l¬Û¤ù").Files.Count - 1
    If myPhoto <> "" Then
        MsgBox (countPhoto)
    Else
        MsgBox "no photo"
    End If
End Sub
HELLO !!

TOP

¥»©«³Ì«á¥Ñ yangjie ©ó 2014-3-31 11:09 ½s¿è

¦^´_ 7# baconbacons
Sub test()
    Dim FileName As Variant
    Dim xlfileName As String
    Dim FolderName As Variant
    Dim f1 As Object
    Set f1 = CreateObject("Scripting.FileSystemObject")
    n= f1.GetFolder(ThisWorkbook.Path ).Files.Count
        MsgBox n
    Set f1 = Nothing
End Sub
¥H¤W  ¸g´ú¸Õ¬O OK  ªº
f1.GetFolder(ThisWorkbook.Path ).Files   ¶È¬O¨S¦³¿z¿ïÀÉ®×Ãþ«¬ªºª«¥ó
§Ú¤]¬O±qª©¥D­Ì«ü¾É¤U  Åé·| ¾Ç¨Óªº
for each a in Object
next
³q±`¬O ¦b¨C¤@­Ó(each a)¶·°µ¦P¤@°Ê§@(©Î¦b¿z¿ï±ø¥ó¤U) ¨Ï¥Î
³o¬O­Ó¤H·Qªk
§Æ±æ¹ï§A¦³©ÒÀ°§U

TOP

¦^´_ 8# yangjie
yangjie¤j¡G
                     ¸Õ¤F¤@¤U¡Aµo²{¤@­Ó¦³½ìªºµª®×¡A¤£ª¾¹D¬O§_¬°¡uGetFolder¡v¹w³]ªº°ÝÃD¡H
                     ´N¬O§Ú¦pªG¦b¬¡­¶Ã¯©Ò¦b¸ê®Æ§¨¤S·s¼W¤@­Ó¦W¬°­ì©l¬Û¤ùªº¸ê®Æ§¨
                     ±N¬Û¤ù¡]©ÎÀɮס^©ñ¦b¸Ó¤l¸ê®Æ§¨ µ²ªG­È¤@¼Ë·|¦h1
                     ´Nºâ¬O§â¸Ó¤l¸ê®Æ§¨²MªÅ µ²ªG­ÈÅã¥Ü¡u1¡v
                     ¤£ª¾¹D¸Ó¦p¦ó¸ÑÄÀ  ·Ð½Ð½ç±Ð

­×§ï«áµ{¦¡½X¦p¤U¡G
Sub test1()
    Dim f1 As Object
    Set f1 = CreateObject("Scripting.FileSystemObject")
    n = f1.GetFolder(ThisWorkbook.Path & "\" & "­ì©l¬Û¤ù").Files.Count
        MsgBox n
    Set f1 = Nothing
End Sub
HELLO !!

TOP

TEST.rar (6.52 KB) ¦^´_ 9# baconbacons
§Ú¥Î¤W­z §@´ú¸Õ §¡¥¿±`

TOP

        ÀR«ä¦Û¦b : ¥Ç¿ù¥XÄb®¬¤ß¡A¤~¯à²M²bµL·Ð´o¡C
ªð¦^¦Cªí ¤W¤@¥DÃD