Solved

Copy files on network drive using fso

Posted on 2008-06-11
2
321 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
ID: 21761672
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
ID: 31466224
Thanks, that worked.  I thought I tried to do that but I guess me mind is just not working.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

867 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

22 Experts available now in Live!

Get 1:1 Help Now