Rabu, 13 Maret 2019

Re: [MS_AccessPros] Drag and Drop files to a form field and save the files to a specific location behind that field.

 

Dear Peter,

Thanks a lot. This is a great Function. I think I may apply it in many other occasions. I wonder if it is possible to copy just one file with any other format, rather than pictures?  If so, this can do exactly what I expect in my previous email. I could do this. first drag a file from the explorer to a textbox to get the path, then copy it to the destination folder. What do you think? Thanks again.

Best Regards,
Kevin

On 13-Mar-2019 12:25 AM, Peter Randløv randlov@post9.tele.dk [MS_Access_Professionals] wrote:
 

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


Den 12-03-2019 kl. 14:28 skrev Kevin qingqinga@yahoo.com [MS_Access_Professionals]:
 

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: Kevin <qingqinga@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar