Copying files - basic.visual
This is a discussion on Copying files - basic.visual ; Hi, how can I copy a file in VBA when the file is open? FILECOPY gives
an error.
Colm,...
-
Copying files
Hi, how can I copy a file in VBA when the file is open? FILECOPY gives
an error.
Colm,
-
Re: Copying files
"colmkav" <colmjkav@yahoo.co.uk> wrote in message
news:1193909458.056042.134050@22g2000hsm.googlegroups.com...
> Hi, how can I copy a file in VBA when the file is open? FILECOPY gives
> an error.
>
> Colm,
AFAIK, you can't. By the way, given that changes
are likely being made, why would you want to?
-
Re: Copying files
On 1 Nov, 13:06, "Norm Cook" <normcookNOS...@cableone.net> wrote:
> "colmkav" <colmj...@yahoo.co.uk> wrote in message
>
> news:1193909458.056042.134050@22g2000hsm.googlegroups.com...
>
> > Hi, how can I copy a file in VBA when the file is open? FILECOPY gives
> > an error.
>
> > Colm,
>
> AFAIK, you can't. By the way, given that changes
> are likely being made, why would you want to?
Surely there must be some way. I can copy it manually. All I want to
do is get date information from it and these wouldnt be altered.
-
Re: Copying files
"colmkav" <colmjkav@yahoo.co.uk> wrote in message
news:1193923161.528799.320440@y42g2000hsy.googlegroups.com...
> On 1 Nov, 13:06, "Norm Cook" <normcookNOS...@cableone.net> wrote:
>> "colmkav" <colmj...@yahoo.co.uk> wrote in message
>>
>> news:1193909458.056042.134050@22g2000hsm.googlegroups.com...
>>
>> > Hi, how can I copy a file in VBA when the file is open? FILECOPY gives
>> > an error.
>>
>> > Colm,
>>
>> AFAIK, you can't. By the way, given that changes
>> are likely being made, why would you want to?
>
> Surely there must be some way. I can copy it manually. All I want to
> do is get date information from it and these wouldnt be altered.
>
Can you not just read it if you are not altering data? If the file is
currently opened for read (not locked), would this not work?
Nigel
-
Re: Copying files
"colmkav" <colmjkav@yahoo.co.uk> wrote in message
news:1193923161.528799.320440@y42g2000hsy.googlegroups.com...
>
> Surely there must be some way. I can copy it manually. All I want to
> do is get date information from it and these wouldnt be altered.
>
If that is true - that you can copy the file in Explorer, while another program
has it open - then you should also be able to open and read the file in VB. Just
open it for binary, read the whole thing, open a new file, and write the whole
thing.
If a file is opened exclusively, then you won't be able to copy it in Explorer,
and won't be able to open and read it in VB either.
-
Re: Copying files
Can't you use the API called:
Public Declare Function CopyFileEx Lib "kernel32.dll" Alias
"CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef
pbCancel As Long, ByVal dwCopyFlags As Long) As Long
Dim Ret As Long
'copy the file
'the below VB command does not always work - I do not know why
'FileCopy sRoot & sTmp, cmd_sw$(2) & Mid$(sRoot & sTmp, 2)
'sRoot & sTmp = current file name
Ret = CopyFileEx(sRoot & sTmp, new_file_name$, 0&, ByVal 0&, 0&, 0&)
'if file was successfully copied, then increment # of total files copied
If Ret <> 0 Then
'file copied okay
'fp.cnt_copied = fp.cnt_copied + 1
List1.AddItem sRoot & sTmp
Else
'file NOT copied
List1.AddItem "NOT COPIED - " & sRoot & sTmp
End If
Otis
colmkav wrote:
> Hi, how can I copy a file in VBA when the file is open? FILECOPY gives
> an error.
>
> Colm,
>
Similar Threads
-
By Application Development in forum RUBY
Replies: 0
Last Post: 09-28-2007, 04:21 PM
-
By Application Development in forum Python
Replies: 0
Last Post: 08-29-2007, 08:01 PM
-
By Application Development in forum Python
Replies: 0
Last Post: 08-29-2007, 01:50 PM
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 05-06-2005, 12:08 PM
-
By Application Development in forum basic.visual
Replies: 1
Last Post: 11-26-2003, 04:21 PM