Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 9th, 2005, 07:19 AM
cvrle cvrle is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Belgrade, Serbia
Posts: 15 cvrle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 13 m 38 sec
Reputation Power: 0
Smile 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

Reply With Quote
  #2  
Old September 9th, 2005, 07:53 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 10
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

Reply With Quote
  #3  
Old September 9th, 2005, 08:20 AM
cvrle cvrle is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Belgrade, Serbia
Posts: 15 cvrle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old September 9th, 2005, 10:49 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 10
You were close with your code but it would have been written with FileCopy:

FileCopy "oldPath + Name" , "newPath + name"

FileCopy STA, GDE

lwells

Reply With Quote
  #5  
Old November 24th, 2006, 10:44 AM
schnadi_uk schnadi_uk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Location: Hull, UK
Posts: 3 schnadi_uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 57 sec
Reputation Power: 0
Smile

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

Reply With Quote
  #6  
Old September 28th, 2007, 03:29 PM
DanAtCorning DanAtCorning is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 1 DanAtCorning User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #7  
Old October 22nd, 2007, 04:49 PM
bhale bhale is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 1 bhale User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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"

Reply With Quote
  #8  
Old February 4th, 2010, 01:59 PM
racekiller racekiller is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 1 racekiller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Copy file using VBA


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap