Find and Move picture files via Access VBA (1 Viewer)

dgaller

Registered User.
Local time
Today, 01:13
Joined
Oct 31, 2007
Messages
60
I am working on a project that I will need to group pictures with an access record. My plan is to put all the pictures as all the "tools" move through the process in a folder on hard drive named with the specific naming system.

Once all the items and pics are complete I would like to have the database create a file and folder for all the different records (I have code for this).

Then I would like to search the folder for all like parts and move them to a new folder.

This is where I am stuck is the code to search for all the pictures starting with a specific name i.e "tool123-*" in a form field and move them into a file based on a path in another form field?
 

darbid

Registered User.
Local time
Today, 07:13
Joined
Jun 26, 2008
Messages
1,428
This is where I am stuck is the code to search for all the pictures starting with a specific name i.e "tool123-*" in a form field and move them into a file based on a path in another form field?

Code:
Set fs = CreateObject("Scripting.FileSystemObject")
Set SelectedFolderTemp = fs.GetFolder("pathToYourFolder")

'Loop through the files in the selected folder
For Each MyFile In SelectedFolderTemp.Files
    If InStr(MyFile.name, "tool123-") > 0 Then
                 'DO WHAT YOU WANT as you have a file you need
          End If
Next
 

Users who are viewing this thread

Top Bottom