Consulting

Results 1 to 2 of 2

Thread: Copy files, from a given list!

  1. #1

    Copy files, from a given list!

    Hi,

    this is my first message, I found a macro that looks powerful even if I didn't try it out it seems to be very close to a tool I need.
    The macro I saw is:
    *ttp://*ww.vbaexpress.com/kb/getarticle.php?kb_id=827
    It appears that this macro copies all the files from a folder to another, and considers different type of errors.
    What I need is, not to copy all the files, but those listed in a column in excel.
    I don't know anything about programming, but someone kindly wrote for me a macro that does the trick. However, that doesn't consider the case the files already exist in the destination folder, or the files listed in the list are not present in the source folder.
    I have no idea on how to modify it but it would be of great help if you could help me to modify this macro so that not all the content of a folder, but only the files specified in a list like in the macro below are subject to copy to another folder. It would be just perfect if I then could run the macro with a hotkey!
    [vba]
    Sub CopiaLista()
    Dim InitialFoldr$
    InitialFoldr$ = "L:\source\"
    With Application.FileDialog(msoFileDialogFolderPicker)
    .Title = "Please select a folder to copy Files from"
    .InitialFileName = InitialFoldr$
    .Show
    PercCorr = .SelectedItems(1) & "\"
    End With

    With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = Application.DefaultFilePath & "\"
    .Title = "Please select a folder to copy Files to"
    .InitialFileName = InitialFoldr$
    .Show
    PercNew = .SelectedItems(1) & "\"
    End With

    For I = 2 To Cells(Rows.Count, 1).End(xlUp).Row 'Elenco file da A2 verso il basso
    NomeFile = PercCorr & Cells(I, 1).Value
    'Name NomeFile As Replace(NomeFile, PercCorr, PercNew)
    FileCopy NomeFile, Replace(NomeFile, PercCorr, PercNew)
    Next I

    End Sub
    [/vba]

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    See if you can adapt what I explained in this thread. http://www.vbaexpress.com/forum/showthread.php?t=26541

Posting Permissions

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