Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #108385

Re: object.CopyFile() has an error?

From Claus Busch <claus_busch@t-online.de>
Newsgroups microsoft.public.excel.programming
Subject Re: object.CopyFile() has an error?
Date 2015-12-26 13:46 +0100
Organization A noiseless patient Spider
Message-ID <n5m234$4fi$1@dont-email.me> (permalink)
References <gfGdnftp9oWZ9OPLnZ2dnUVZ5tWdnZ2d@giganews.com>

Show all headers | View raw


Hi Robert,

Am Sat, 26 Dec 2015 03:16:34 -0700 schrieb Robert Crandal:

> If you run the above code once, file1.txt will successfully
> be copied into C:\data.  However, run the code for a second
> time and you get a run-time error 58 message that says:
> "File already exists".
> Why does this error message appear?  I've set the overwrite
> option to False, meaning do NOT overwrite.

VBA help says that you get this error if the file in the target exists
and overwrite = false
So you have to check if the file exists before running the code.

> If I set the overwrite flag to True, the file inside C:\data
> never gets overwritten.  No matter how many times I try.
> (Neither files are set to Read Only)

I had no problems to overwrite the file. True is default. Don't need to
write it:
fo.CopyFile "C:\file1.txt", "C:\Ordner1\file1.txt"
Do you have all the rights for "C:\" ?


Regards
Claus B.
-- 
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

Back to microsoft.public.excel.programming | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

object.CopyFile() has an error? "Robert Crandal" <noreply2me@yahoo.com> - 2015-12-26 03:16 -0700
  Re: object.CopyFile() has an error? Claus Busch <claus_busch@t-online.de> - 2015-12-26 13:46 +0100
  Re: object.CopyFile() has an error? GS <gs@v.invalid> - 2015-12-26 14:24 -0500
    Re: object.CopyFile() has an error? "Robert Crandal" <noreply2me@yahoo.com> - 2015-12-26 13:18 -0700
      Re: object.CopyFile() has an error? GS <gs@v.invalid> - 2015-12-26 15:24 -0500
      Re: object.CopyFile() has an error? Claus Busch <claus_busch@t-online.de> - 2015-12-26 22:48 +0100
        Re: object.CopyFile() has an error? "Robert Crandal" <noreply2me@yahoo.com> - 2015-12-26 16:17 -0700
          Re: object.CopyFile() has an error? GS <gs@v.invalid> - 2015-12-26 18:34 -0500
            Re: object.CopyFile() has an error? "Robert Crandal" <noreply2me@yahoo.com> - 2015-12-26 16:56 -0700

csiph-web