Solved

vba fso

Posted on 2013-06-11
2
391 Views
Last Modified: 2013-06-11
Hello,

Need a robust vba code that does this.

There is a network folder called gdfgf/fdsfsdf which has a particular csv file.
1.      Create a folder (if it doesn’t exist in C drive by the name: C:\newTemp
2.      Copy the target csv from the network folder and dump it in the newly created folder (C:\newTemp)
3.      Do some stuff with the csv (code not needed for this step)
4.      Delete the folder that has the csv

Thank you
0
Comment
Question by:Rayne
[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
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 39238787
Assuming your user acct has the right permissions...


Dim fso, fil, fld

Set fso = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

Set fil = fso.GetFile("\\servername\share\folder\subfolder\blah.csv")
' Set fil = fso.GetFile("\\servername\c$\folder\subfolder\blah.csv")

If Err <> 0 Then
    MsgBox "blah.csv does not exist"
Else
    Set fld = fso.GetFolder("c:\newTemp")
    If Err <> 0 Then fso.CreateFolder("c:\newTemp")
    fil.Copy "c:\newTemp\blah.csv", True
    ' do stuff to file
    fld.Delete True
End If

Set fil = Nothing
Set fld = Nothing
Set fso = Nothing

On Error GoTo 0

Open in new window

0
 

Author Comment

by:Rayne
ID: 39238910
Thanks Patrick :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

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