|
 |
|
Dev Articles Community Forums
> Databases
> Microsoft Access Development
|
Copy file using VBA
Discuss Copy file using VBA in the Microsoft Access Development forum on Dev Articles. Copy file using VBA Microsoft Access Development forum to discuss problems and solutions with this popular DBMS. Use Access to build and modify database tables, or full-featured applications.
|
|
 |
|
|
|
|

Dev Articles Community Forums Sponsor:
|
|
|

September 9th, 2005, 07:19 AM
|
|
Registered User
|
|
Join Date: May 2005
Location: Belgrade, Serbia
Posts: 15
Time spent in forums: 10 h 13 m 38 sec
Reputation Power: 0
|
|
Copy file using VBA
This must be easy, but in my case just don't work.
How to copy file from one folder to another using VBA ?
Thanks
|

September 9th, 2005, 07:53 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Posts: 632
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 9
|
|
|
Can you post what you tried? The generic method is:
Dim fs As Object
Dim oldPath As String, newPath As String
oldPath = "C:\Documents and Settings\user\My Documents" 'Folder file is located in
newPath = "C:\Documents and Settings\user\My Documents\Misc" 'Folder to copy file to
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath & "\" & "Query1.xls", newPath & "\" & "Query1.xls" 'This file was an .xls file
Set fs = Nothing
lwells
|

September 9th, 2005, 08:20 AM
|
|
Registered User
|
|
Join Date: May 2005
Location: Belgrade, Serbia
Posts: 15
Time spent in forums: 10 h 13 m 38 sec
Reputation Power: 0
|
|
|
I tried this but it did not worked. Your advise helped and the file is copied at last, thank you.
Dim STA As String
Dim GDE As String
STA = "c:\dejan\racuni.dbf"
GDE = "c:\proba\"
FileSystemObject.CopyFile STA, GDE
|

September 9th, 2005, 10:49 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Posts: 632
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 9
|
|
|
You were close with your code but it would have been written with FileCopy:
FileCopy "oldPath + Name" , "newPath + name"
FileCopy STA, GDE
lwells
|

November 24th, 2006, 10:44 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Location: Hull, UK
Posts: 3
Time spent in forums: 34 m 57 sec
Reputation Power: 0
|
|
I know this thread is a little outdated but I have used code similar to that shown above and my problem is that everything is copied...including the last date modified attribute. Is there any way to change this to the current date?
Thanks in advance,
schnadi
|

September 28th, 2007, 03:29 PM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 1
Time spent in forums: 23 m 15 sec
Reputation Power: 0
|
|
|
I have some code which is copying a file from a local hard drive to a share drive; it then uploads that share-drive copy to a LIMS system. I need to make sure that the filecopy is complete prior to continuing with the rest of the code,; otherwise it will crash if it tries to upload a file that does not exist (or is incomplete). I wan to use a "FileExists" function I've created, but I'm not sure if that will work since I don't know if the filename will be created at the front end of the filecopy. If the filename is created, and it is still in the process fo copying when it checks to see if filename exists, will it find the name, even though the copying is not complete? If so, I haven't accomplished anything.
|

October 22nd, 2007, 04:49 PM
|
|
Registered User
|
|
Join Date: Oct 2007
Posts: 1
Time spent in forums: 5 m 28 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by cvrle This must be easy, but in my case just don't work.
How to copy file from one folder to another using VBA ?
Thanks |
FileCopy "C:\TEST1\X.TXT", "C:\TEST2\Y.TXT"
|

February 4th, 2010, 01:59 PM
|
|
Registered User
|
|
Join Date: Feb 2010
Posts: 1
Time spent in forums: 3 m 16 sec
Reputation Power: 0
|
|
|
The destination file is getting lost
Quote: | Originally Posted by bhale FileCopy "C:\TEST1\X.TXT", "C:\TEST2\Y.TXT" |
Hi guys,
I am using same code to overwrite a file but sometimes the destination files is getting lost...some how the code is deleting it.
Do you have any idea, what could be happening?
I appreciate your help
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|