Consulting

Results 1 to 2 of 2

Thread: Copy and combine files using VBA

  1. #1

    Question Copy and combine files using VBA

    Hi I have a directory with a number of txt files in eg A1.txt A2.txt Ae.txt I want to copy them all to a different directory and combine them in a single file

    Set fso = CreateObject("Scripting.FileSystemObject")

    From_File = "C:\temp\*.*"
    To_File = "C:\fred.txt"

    fso.CopyFile From_File, To_File, True

    However when I run the above I get a file path error if I change to_File C:\ it copies the individual files perfectly.

    Does copyfile not allow you to copy as per dos?

    Thanks

    John

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    See here
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Tags for this Thread

Posting Permissions

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