Is there a faster, more efficient way to copy a file to a new location? I have some rather small .jpg's that are moved upon request, but it seems to be taking 20-30 seconds each while using the FileCopy() method.
Is there a faster, more efficient way to copy a file to a new location? I have some rather small .jpg's that are moved upon request, but it seems to be taking 20-30 seconds each while using the FileCopy() method.
Can use API code but doubt it will be much faster than the intrinsic VBA FileCopy().
Bing: API file copy
http://www.freevbcode.com/ShowCode.asp?ID=498
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thanks, I will give it a try and see if there's a noticeable difference.
Just thought I'd let you know I was able to get around to trying this method. Copy time reduced from ~25 seconds down to less than 1 second.
Really, that is interesting. Perhaps I should revisit my code. Glad it worked for you.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I performed one immediately after the other, same file. The difference was staggering. Not sure if this is applicable to all file types, but it sure is faster regarding jpegs
Does this method work in Excel? I'm trying to run the exact same code within excel to move a couple files, but it won't copy the file over.
Yes, it works.
The code must be in a general code module.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
It is in a regular module in my personal workbook.
And in a function later...Code:Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Is there a reference library I need for this to run?Code:If dir("S:\Shared\Quality\PQG\Kris\Locations Reports\Final Summaries\Test", vbDirectory) = "" Then MkDir "S:\Shared\Quality\PQG\Kris\Locations Reports\Final Summaries\Test" CopyFile "S:\Shared\Quality\PQG\Kris\Locations Reports\Background\Affected.xlsx", "S:\Shared\Quality\PQG\Kris\Locations Reports\Final Summaries\Test\Affected - " & Format(Now(), "m/d/yyyy") & ".xlsx", False CopyFile "S:\Shared\Quality\PQG\Kris\Locations Reports\Background\Affected Locations.xlsx", "S:\Shared\Quality\PQG\Kris\Locations Reports\Final Summaries\Test\Locations Report - Test - " & Format(Now(), "m/d/yyyy") & ".xlsx", False
Figured it out, had to do with the title of the new file location. Cannot include the character "/".
As an alternative to using an API, I have had pretty good results referencing the Microsoft Scripting Runtime
https://www.accessforums.net/access/...tml#post287123