Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CopyFolder problem

Posted on 2003-12-04
1
Medium Priority
?
270 Views
Last Modified: 2011-08-18
Hi All,


1) I'm testing the CopyFolder method of FSO, and found that it does not copy files in the root source directory.  Is that normal?

I.e. if I have 3 files and 3 folders under the source directory, all, except the 3 files in the root source directory, were copied over to the target directory, includes files under the source's sub-directory.

2) How can I set the attributes of all files under a specific directory?

Thanks!
0
Comment
Question by:kwseow
[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
1 Comment
 

Accepted Solution

by:
VKPP earned 375 total points
ID: 9880136
Hi

For yor first question , you can copy all folders and files from one folder to another.

Dim MyObj As New FileSystemObject
Dim MyFolder As Folder
Dim MyFile As File
Dim spath As String, dpath As String

spath = "SourcePath\SFolder"
dpath = "DestinationPath\DFolder"

If MyObj.FolderExists(spath) Then
    MyObj.CopyFolder spath, dpath
End If

This above "CopyFolder" will copy all folders and files.

2) To change attributes of all files in a folder

Set MyFolder = MyObj.GetFolder(dpath)

For Each MyFile In MyFolder.Files
    MyFile.Attributes = ReadOnly ' Whatever you want to set
Next

Hope this will solve ur problem.

VKPP
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses

670 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