Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
File Copy in VBA
Glenn Kraniske 
    
4 years ago
Hello All,
After beating my head against the wall with this, I'm finally reaching out for help.  I created a command button to copy files from one location to another when clicked.  I've looked all over for the solution, which isn't readily apparent but I'm coming up dry.  Here is my code;
____________________________________________________________

Private Sub Command142_Click()
Shell "Net Use S: /DELETE", vbHide
Shell "Net Use S: \\WIN-SERVER-001\Attachments", vbHide
Shell "Copy S:\*.* C:\Users\%USERNAME%\Documents\", vbHide
Shell "Net Use S: /DELETE", vbHide
MsgBox "File Copied Successfully!"
End Sub

___________________________________________________________

When I click the button I get a runtime error that points to the following line;
___________________________________________________________
Shell "Copy S:\*.* C:\Users\%USERNAME%\Documents\", vbHide
__________________________________________________________
The runtime error says "File not found"


Any help would be appreciated.  Thanks.
Kevin Robertson  @Reply  
          
4 years ago
There's a function in the Code Vault called CopyFileA. Shell is used for running an executable program.
Richard Rost  @Reply  
          
4 years ago
Why would you want to shell out to a batch file when Access has built-in file i/o that can handle the copy internally? See Access Developer 34.
Richard Rost  @Reply  
          
4 years ago
As far as the NET USE stuff goes, I've never had luck with that running reliably. Is there a reason why you want to create and then delete that share? If you're trying to hide the folder from users, just install Hide Folders.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 2:37:52 PM. PLT: 0s