Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default Copy file with a macro

I want to copy a file from one folder to another with a macro. Can someone
help please?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Copy file with a macro

Use the FileCopy command:


Sub CopyAFile()
Dim FromFileName As String
Dim ToFileName As String
FromFileName = "C:\Test\FileToCopy.txt"
ToFileName = "C:\Test2\FileToCopy.txt"
FileCopy Source:=FromFileName, Destination:=ToFileName
End Sub

Note that destination folder must exist, otherwise you'll get a "Path Not
Found" error. Use the MkDir function to create a new folder if necessary.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Brettjg" wrote in message
...
I want to copy a file from one folder to another with a macro. Can someone
help please?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default Copy file with a macro

Thankyou Chip

"Chip Pearson" wrote:

Use the FileCopy command:


Sub CopyAFile()
Dim FromFileName As String
Dim ToFileName As String
FromFileName = "C:\Test\FileToCopy.txt"
ToFileName = "C:\Test2\FileToCopy.txt"
FileCopy Source:=FromFileName, Destination:=ToFileName
End Sub

Note that destination folder must exist, otherwise you'll get a "Path Not
Found" error. Use the MkDir function to create a new folder if necessary.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Brettjg" wrote in message
...
I want to copy a file from one folder to another with a macro. Can someone
help please?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
On a DDE Linked worksheet : Copy and Paste Value to a to a file via a macro ? Martin Links and Linking in Excel 0 November 20th 06 11:19 AM
recrding macro,copy data thn close file, get messge abut clpbord PaddyBoy Excel Discussion (Misc queries) 2 October 25th 06 04:38 AM
Using Macro to Save Copy of File to New Location Chris Z Excel Discussion (Misc queries) 3 September 12th 06 11:26 PM
creat a macro to save a copy with different file name yrndtn Excel Discussion (Misc queries) 2 September 8th 06 01:14 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM


All times are GMT +1. The time now is 08:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"