Consulting

Results 1 to 2 of 2

Thread: filesystemobject

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    filesystemobject

    Hello

    Every time i use the copyfolder method as :

    Set MyFolder = fso.CreateFolder("C:\MyDocs\ReportingDatabase" & "\" & SaveDate)

    Ms fso.CopyFolder "C:\MyDocs\Reporting Database\Reports","C:\MyDocs\Reporting Database" & "\" & SaveDate

    It copies the contents of the folder rather than the folder itself. The file structure within Reporting Database is that there a subfolder called Reports. I create a new subfolder under Reporting Database and give it the name of the reporting date which i have saved to a variable SaveDate. I want to copy the folder Reports (which has a load of spreadsheets in it) and put it in the new dated subfolder for a new set of reports to be generated. This process will be repeated each month with a new subfolder for a new date.

    Any ideas???

    Thanks

    phil

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by philfer
    Ms fso.CopyFolder "C:\MyDocs\Reporting Database\Reports","C:\MyDocs\Reporting Database" & "\" & SaveDate
    I am presuming the 'Ms' is a typo?

    I believe you need the trailing seperator in the destination directory.
    Sub exa()
    Dim FSO As FileSystemObject
    Dim fsoFolder As Folder
        
        Set FSO = New FileSystemObject
        Set fsoFolder = FSO.CreateFolder("D:\2010\2010-05-16\CreatedFolder")
                                                            'Needs trailing seperator
        FSO.CopyFolder "D:\2010\2010-05-16\ReWrite_DistributedCode", fsoFolder.Path & "\"
    End Sub
    Hope that helps,

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •