Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Move\Copy Files with\without override

Posted on 2003-12-08
Medium Priority
Last Modified: 2010-05-18
What different methods are available ?

Thank You
Question by:AlexF777
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
LVL 33

Accepted Solution

hongjun earned 375 total points
ID: 9898483
try this
include "Microsoft Scripting Runtime" from project-references

Dim fso As FileSystemObject

Set fso = New FileSystemObject
fso.CopyFile "c:\sourcefile.txt", "c:\destination.txt", False
fso.MoveFile "c:\sourcefile.txt", "c:\destination.txt"

Set fso = Nothing

LVL 33

Expert Comment

ID: 9898489
' false means do not override
' true means override
fso.CopyFile "c:\sourcefile.txt", "c:\destination.txt", False

LVL 33

Expert Comment

ID: 9898493
to check if file exists, do this

If fso.FileExists("c:\myfile.txt") Then
    MsgBox "File Exist"
End If

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 33

Expert Comment

ID: 9904535
Thanks for selecting my comment as the answer. But why the grade of "B"? It could have been an A grade since my comment solved your problem directly. Note that a grade A given does not differ from a grade B or C to a questionner. It will not affect your question points value but rather it only affect your grading record. Your grading record will be better if you shows consistent A grading awarding habit.

Please see Tip #11 - Grade quickly and fairly

Please explain the reason for the B grade.


Author Comment

ID: 9909466
Ok, what I am trying to accomplish is to override destination files if they already exist ( would be nice to be able
to use wild-cards too ).

fso.CopyFile will do it but only if destination is not read-only, fso.MoveFile -will not do it at all.

may be I am wrong ?


LVL 33

Expert Comment

ID: 9909474
Perhaps you try using Shell api


Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question