Solved

Copy files on network drive using fso

Posted on 2008-06-11
2
320 Views
Last Modified: 2010-04-30
I had a question opened earlier today about moving a files from one directory to another using a vb script.  The script provided help me on my local drive....but I have additional uses for it.  I modified the variables and tried to process on my network but keep getting an error message that the files are not found. I checked the location of the files and they are there.  I know there is probably a simple error in the changes I made.  I have attached the code for reference.
Sub ArchiveFiles()

    Dim fso As Object

    

    Dim sSourceDir As String

    Dim sTargetDir As String

    

    sSourceDir = "K:\Public\Marketing Secure\Shared\"

    sTargetDir = "K:\Public\Marketing Secure\Shared\Oracle Files\"

    

    Set fso = CreateObject("Scripting.FileSystemObject")

    

    fso.movefile Source:="Costs*.xls", Destination:=sTargetDir

    fso.movefile Source:="Status*.xls", Destination:=sTargetDir

    

End Sub

Open in new window

0
Comment
Question by:ilrosebud26
2 Comments
 
LVL 22

Accepted Solution

by:
danaseaman earned 125 total points
Comment Utility
Try this:
Sub ArchiveFiles()

    Dim fso As Object

    

    Dim sSourceDir As String

    Dim sTargetDir As String

    

    sSourceDir = "K:\Public\Marketing Secure\Shared\"

    sTargetDir = "K:\Public\Marketing Secure\Shared\Oracle Files\"

    

    Set fso = CreateObject("Scripting.FileSystemObject")

    

    fso.movefile Source:=sSourceDir & "Costs*.xls", Destination:=sTargetDir

    fso.movefile Source:=sSourceDir & "Status*.xls", Destination:=sTargetDir

    

End Sub

Open in new window

0
 

Author Closing Comment

by:ilrosebud26
Comment Utility
Thanks, that worked.  I thought I tried to do that but I guess me mind is just not working.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

10 Experts available now in Live!

Get 1:1 Help Now