Solved

filecopy in VB6

Posted on 2006-11-06
11
1,530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
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.
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

739 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