Solved

filecopy in VB6

Posted on 2006-11-06
11
1,508 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
Comment Utility

Programming is in Access 2003
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Show us your code.
0
 
LVL 4

Expert Comment

by:programmer1024
Comment Utility
Probably have to reference the FileSystemObject.
0
 

Author Comment

by:bin2003
Comment Utility

Code is : VB 6

    VarReturn=FileCopy(strsource,strDest)
0
 
LVL 1

Accepted Solution

by:
ms_sanjay earned 500 total points
Comment Utility
Hi Bin2003,
   Try this

FileCopy StrSource,StrDest.

Hope it helps.

Thanks
Sanjay Samuel.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Expert Comment

by:markerrington
Comment Utility
Use FileSystemObject

Dim oFSO as new FileSystemObject

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

Expert Comment

by:rixlabs
Comment Utility
0
 
LVL 2

Expert Comment

by:Zak-R
Comment Utility

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

0
 

Expert Comment

by:dhavalislovely
Comment Utility
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
Comment Utility
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
Comment Utility

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
canBalance challenge 34 65
find a node in VST 2 46
Fibonacci challenge 11 82
Tviruailstringtree sort multi columns on header click 1 29
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …
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 …

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now