Solved

filecopy in VB6

Posted on 2006-11-06
11
1,518 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

831 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