Dear Kevin
I am not sure I understand exactly what you want to do, but I do occasionally have to copy the files from a query to a directory, e.g. to find and copy all images from Greenland out of 30.000 images in 90 directories.
1. I run a query
2. Copy LBNR to e new table. LBNR is the unique id for each image.
3. Run the function below, and voila, all the pictures are there.
Is it something you can use?
Best regards
Peter
Function CopyJPGs()
'Run a query (e.g. MotivQ), copy the column LBNR to a new table with the column as text.
'The new table must have same name as in the command Set rs = CurrentDb.OpenRecordSet("NyTabel", dbOpenSnapshot)
'Run/Sub or F5. The files are now copied to E:\RODS\RODS\TEMP\
Dim rs As Recordset
Dim lng As Long
Dim Samler As String
Dim SourceDir As String
'Dim TargetDirectory As String
Dim Filename As String
Dim PathFile As String
Const SourceDirectory = "E:\RODS\RODS\SAMLING\" 'OBS: Direktorie E:\ kan være ændret
Const TargetDirectory = "E:\RODS\RODS\TEMP\"
Set rs = CurrentDb.OpenRecordset("NyTabel", dbOpenSnapshot)
Do Until rs.EOF
Samler = rs!LBNR
Samler = Left([Samler], 2) 'The name of the subdirectory extracted from the filename
SourceDir = SourceDirectory & Samler
Filename = rs!LBNR & ".jpg"
PathFile = SourceDir & "\" & Filename
FileCopy PathFile, TargetDirectory & Filename
lng = lng + 1
rs.MoveNext
Loop
MsgBox lng & " files copied to " & TargetDirectory & ".", vbInformation
End Function
Dear Crystal,
I got it. Thanks a lot.
Best Regards,
Kevin
On 12-Mar-2019 12:32 PM, crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals] wrote:
hi Kevin,
good question, Kevin. Dragging is difficult to do, and even more so when
the other application isn't Access. I usually copy the path name in
Windows Explorer than paste it in the filename box and press ENTER when
I browse for files. You could collect a path then populate a listbox
with the files found and let the user pick what they want if you want it
pick on a form ... much easier than dragging
have an awesome day,
crystal
free code you can use in your projects
https://msaccessgurus.com/code.htm
On 3/11/2019 4:49 AM, Kevin qingqinga[MS_Access_Professionals] wrote:
> Dear All,
>
> I have a textbox in a form storing the path of a folder. Is that
> possible to drag files from other location of explorer to this field, so
> that the files are save in the path behind it? Thanks in advance.
>
> Best Regards,
>
> Kevin
>
>
>
> ------------------------------------
> Posted by: Kevin <qingqinga@yahoo.com>
> ------------------------------------
>
>
> ------------------------------------
>
> Yahoo Groups Links
>
>
>
Posted by: Peter =?iso-8859-1?q?Randl=F8v?= <randlov@post9.tele.dk>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
Tidak ada komentar:
Posting Komentar