Solved moving files using partial names

follower2020

New member
Local time
Today, 19:53
Joined
May 14, 2020
Messages
9
hello everyone

If i have many pdf files with names say :

999 jane
999jane
999 jane d

I want to move all the files starting with 999 to a specific folder
I am getting error in this part : Name "C:\Users\Modhy\Desktop\Scanner\" & Me.Casenumber & "" & "*.pdf"

what is wrong with this part ( Me.Casenumber & "" & "*.pdf" )

casenumber is the 999

Thank you
 
Code:
    Dim sPath As String
    Dim sNewPath As String
    Dim sFile As String

    sNewPath = "X:\AnyWhere\XY"

    sPath = "X:\AnyWhere\"              
    sFile = Dir(sPath & "999*.pdf")                    
    Do While sFile > vbNullString                  
        'Debug.Print sFile                          
        Name sPath & sFile As sNewPath & "\" & sFile

        sFile = Dir                                
    Loop
Other ways of moving would be using xcopy or robocopy.
 
Last edited:
Dear ebs17

Great. Thank you for your assistance.

I have tested it.
 

Users who are viewing this thread

Back
Top Bottom