copyFile not recognize

copyFile not recognize

Anonymous
Not applicable
896 Views
6 Replies
Message 1 of 7

copyFile not recognize

Anonymous
Not applicable
Hello People:
Anyone know what reference is for copyFile, because visualbasic not recognize this command, thanx!!
0 Likes
897 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
You may be thinking of the FileCopy function but I also found this code on
the net which may be what your looking for.

HTH,

Dale.


Public Function CopyFile(srcefile As String, destfile As String, _
errnum As Integer) As Boolean
'*****************************************************************
' Copies individual files to new location.
' Boolean:
' Success level of function

' Public
' srcefile:
' Full Filepath & Filename of source
' destfile:
' Full Filepath & Filename of destination
'

' blnCopy = CopyFile("c:\autoexec.bat", _
' "c:\temp\autoexec.old", 0)

'*****************************************************************

Dim intAttr As Integer

DoEvents
CopyFile = False

On Error Resume Next

Err = 0
FileCopy srcefile, destfile

Select Case Err
Case 0 ' OK
CopyFile = True
Case 75 ' Path/File Access error
intAttr = GetAttr(destfile)
SetAttr destfile, vbNormal
Err = 0
FileCopy srcefile, destfile
If Err = 0 Then
intAttr = intAttr Or vbArchive
SetAttr destfile, intAttr
CopyFile = True
Else
errnum = Err
End If
Case Else ' Other error
errnum = Err
End Select

End Function wrote in message
news:5065026@discussion.autodesk.com...
Hello People:
Anyone know what reference is for copyFile, because visualbasic not
recognize this command, thanx!!
0 Likes
Message 3 of 7

fxcastil
Advocate
Advocate
see attached the file, add a reference to MicroSoft Scripting
dll file.

This dll has many file handling capabilites, use the object browser to see all the features. Also search the internet
for "File system object" for more samples on using this.

Fred C
0 Likes
Message 4 of 7

Anonymous
Not applicable
It is not recommended to use Scripting.FileObject in VB/VBA program, unless
you have no other choice. There are many discussions on this topic in many
VB/VBA related NGs and on the net. VB/VBA's intrinsic file handling
functions can do everything Scripting.FileObject does.

wrote in message news:5065260@discussion.autodesk.com...
see attached the file, add a reference to MicroSoft Scripting
dll file.

This dll has many file handling capabilites, use the object browser to see
all the features. Also search the internet
for "File system object" for more samples on using this.

Fred C
0 Likes
Message 5 of 7

Anonymous
Not applicable
Norman,

Where did you here that !
I have read many VBA and VB books and not one ever said
do not use the scripting dll or file system object. Even microsoft describes how it easier to use the file system object
than VBA file handling functions.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office09072000.asp

Yes VBA does have a filecopy which performs the same function as a File System object copyFile.

But to say that "VBA intrinsic file handling functions can do everything Scripting.FileObject does"

That is just not a true statement see attached file.

Maximo
0 Likes
Message 6 of 7

Anonymous
Not applicable
This topic has been beaten to death long time ago and I do not want to
repeat it all the benifit of not using Scripting.FileSystem in VB/VBA, nor I
could remember all the arguments n this. Just name one of them that is
enought to make me stay away with it in my VB/VBA code:

You unnecessarily add a reference/dependency to your code. Not to mention
different version issue if the users could be using Win98 (or even Win95) to
WinXP.

If you search various VB NGs, you would find many threads on this topic and
almost for each original post, there would be one a more VB/VBA MVP
suggesting not to use Scripting.FileSystem, use VB/VBA intrinsic functions
instead


wrote in message news:5065594@discussion.autodesk.com...
Norman,

Where did you here that !
I have read many VBA and VB books and not one ever said
do not use the scripting dll or file system object. Even microsoft describes
how it easier to use the file system object
than VBA file handling functions.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office09072000.asp

Yes VBA does have a filecopy which performs the same function as a File
System object copyFile.

But to say that "VBA intrinsic file handling
functions can do everything Scripting.FileObject does"

That is just not a true statement see attached file.

Maximo
0 Likes
Message 7 of 7

Anonymous
Not applicable
I also heard the sky is falling but I could not remember all the arguments on this either. If you search the internet it was mentioned somewhere on the internet. That is why I am keeping my head in the ground

Regards
0 Likes