Solved

filecopy in VB6

Posted on 2006-11-06
11
1,522 Views
Last Modified: 2008-01-09

When I try to copy files in VBA I get the following Error;

Compile error: expected Function or variable. Am I missing library reference?

Seems like in can not file the function FileCopy in a library.

0
Comment
Question by:bin2003
11 Comments
 

Author Comment

by:bin2003
ID: 17883760

Programming is in Access 2003
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17883765
Show us your code.
0
 
LVL 4

Expert Comment

by:programmer1024
ID: 17884013
Probably have to reference the FileSystemObject.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:bin2003
ID: 17884519

Code is : VB 6

    VarReturn=FileCopy(strsource,strDest)
0
 
LVL 1

Accepted Solution

by:
ms_sanjay earned 500 total points
ID: 17886304
Hi Bin2003,
   Try this

FileCopy StrSource,StrDest.

Hope it helps.

Thanks
Sanjay Samuel.
0
 

Expert Comment

by:markerrington
ID: 17888163
Use FileSystemObject

Dim oFSO as new FileSystemObject

oFSO.Copy ([File to copy],[Destination])
0
 
LVL 3

Expert Comment

by:rixlabs
ID: 17889423
0
 
LVL 2

Expert Comment

by:Zak-R
ID: 17896045

are you trying to copy a file to another location?
for example: file.exe from "C:\" to "C:\WINDOWS" ?

0
 

Expert Comment

by:dhavalislovely
ID: 17896098
hi,

Try to use as following,

FileCopy "c:\d.htm", "d:\d.htm"

Here d.htm is the file that you want to copy from c: to d:

Best Regards,
Dhaval.

0
 
LVL 1

Expert Comment

by:sagaragrawal
ID: 17897047
FileCopy will do the needful.

Actually its a Sub, which cannot return anything. So, you should not try to accept the return val of FileCopy Subroutine, means you should not write anything on the left hand side of the FileCopy procedure call.

Enjoy !!!
0
 
LVL 2

Expert Comment

by:Zak-R
ID: 17904405

This code will do the job even better:

Dim mByte() As Byte
Open "C:\FileName.exe" For Binary As #1
Open "C:\WINDOWS\Any-Name.exe" For Binary As #2
ReDim mByte(0 To LOF(1))
Get #1, , mByte()
Put #2, , mByte()
Close #1
Close #2

If you want to change the name of the original app for out put you can do that too.
point to the folder where the file is, then select the destination folder for the copy.

Good luck
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

828 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